I have a php based site with wordpress installed in a subdirectory.
The main php site has urls in the following form
http://www.smokescreencreative.co.uk/nameofpage
which are rewritten using htaccess so they actually access pages like so:
http://www.smokescreencreative.co.uk/index.php?pid=$1
This all works as needed. My problem is with the /blog subdirectory. When in the blog part of the site trying to click on a link back to the main part of the site actually directs to
http://www.smokescreencreative.co.uk/blog/nameofpage
instead of
http://www.smokescreencreative.co.uk/nameofpage
as required and I am getting a 404 error because there is nothing there. I think this must be down to my htaccess files but I can't work out how to make it so the links to the main php page take the form I want but the blog post etc stay in the /blog/nameofpage format.
I did manage to get it so /blog/nameofpage was bringing in the correct written content for the root pages but there was no styling or images and the url was still /blog/nameofpage and I would like it to be just /nameofpage if possible.
I've posted the htaccess code for the root directory and blog subdirectories below. any help with this would be much appreciated.
Thanks in advance
main root htaccess code: (works for the links in the root part of the site)
AddType application/x-httpd-php .php .html .htm
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /index.php?pid=$1 [L]
htaccess code for the wordpress subdirectory
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Related
I'm a new user and frankly, I haven't got a clue what I'm doing at this point. I'm figuring things out slowly but surely and this site has so far been a gold mine for me... So, let's see if we can make this work.
So, my website has a WordPress installation within the root directory to allow me to have a blog; WordPress is installed solely for the blog and this is in the public_html/wp folder. Everything within the wp folder is WordPress.
Now, when I write a post, the permalink is my-website.co.uk/wp/post-title.
The .htaccess file rewrites this permalink to my-website.co.uk/blog/post-title.
This is great, looks much better but the problem is, when WordPress auto-shares the posts, the /wp/post-title permalink redirects to homepage and not to the relevant blog post. This means, whenever someone clicks on the shared link, they're taken to my homepage (sorry if I sound like I'm dumbing it down).
Now, in the public_html folder, I have one .htaccess file which is as follows
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(.+?)/do-not-touch.php do-not-touch.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(.+?)/?$ $1.htm [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]
RewriteRule ^blog/([0-9-]+)/?$ blog.php?page=$1
RewriteRule ^blog/([A-Za-z0-9-]+)/?$ blog.php?slug=$1
RedirectMatch 301 ^/tenants.htm /information-for-tenants.htm
Then, in the WP folder, we have another .htaccess file:
#+PHPVersion
#="php70"
AddHandler x-httpd-php70 .php
#-PHPVersion
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
My theory (remember, I have no idea what I'm doing) is that the second .htaccess file redirects the /wp/ permalinks up to the public_html file index (shown by the RewriteBase /wp/ RewriteRule ^index\.php$ --- Not sure what the \.php$ does) whilst the first .htaccess file rewrites the /wp/post-title to /blog/post-title (shown by RewriteRule ^blog/([0-9-]+)/?$ blog.php?page=$1 and RewriteRule ^blog/([A-Za-z0-9-]+)/?$ blog.php?slug=$1).
Finally, in my WordPress admin permalink settings, the selected permalink is shown as my-website.co.uk/wp/sample-post/.
All permalinks are my-website.co.uk/wp/[customisable] -- In other words, it doesn't allow me to alter the /wp/ section of the permalink.
I could really use some help. I need to redirect wp/post-title (whatever the title may be) to blog/post-title instead of /index.
As a result of the redirect, search engines fail to crawl my blog posts (I think?).
This is my website blog: https://www.harryalbertgroup.co.uk/blog
And this is the WP permalink: https://www.harryalbertgroup.co.uk/wp
Thanks in advance.
(Note: This website was built for me. I've been slowly fixing all of the issues I've faced so far. We're slowly getting there, it's really just the sharing features that I need to fix now, from what I can see)
I'm trying to create a rewrite rule in htaccess to point a directory at a file, I keep getting 404 errors in return. I should mention, the main site is a wordpress site and I'm trying to redirect one of it's url's internally for a page with a trailing folder to another url.
For instance, this is the url for the wordpress page:
/homes-for-sale-details/4420/217007490/177/
The landing page I'm trying to create within that url is:
/homes-for-sale-details/4420/217007490/177/Fb-landing-page
So I did this:
RewriteRule /homes-for-sale-details/4420/217007490/177/Fb-landing-page/(.*)$ /propertylisting1/index.php?success=$1
No go, I get a 404 error in return. The wordpress page still work, but this won't.
Right now this new rule is placed after wordpress' own rewrite:
RewriteRule . /index.php [L]
I've also tried placing it before wordpress' rewrite and it breaks all my wordpress pages.
I had it in the wrong place, after much testing I found out if I place this rewrite before the RewriteCond statements, it works, and it doesn't brake other Wordpress rewrites.
So the final is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^homes-for-sale-details/4420/217007490/177/Fb-landing-page(.*)$ propertylisting1/index.php?success=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Okay. So I have a site that needs to be live around 8am EST. Everything was going fine, but when I uploaded it to the server my two pages return 404 not found errors. Absolutely everything else on the site is fine.
I have tried several things. I have reset the permalinks several times. I have deleted auto-saved files in the database. I have re-uploaded the database. I have re-uploaded the site. I have set the permission on .htaccess. I have deleted .htaccess and let it rewrite itself. Nothing has worked. Does anyone have any ideas?
The page works when it is set to default, but NOT when it is set to anything else.
Update This is the .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Based on the .htaccess you can make these changes... although this is the default .htaccess for Wordpress it looks like it has an extra slash in front of index.php for the main redirect line. You'll also want to check to make sure that your Virtual Host Apache directory contains AllowOverride All.
In this example we're telling Apache if the request isn't for index.php then see if it's a real file and a real directory, then if it's not show them the default page. This is similar to the default behavior of Wordpress already.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* index.php [L]
</IfModule>
# END WordPress
There is also a whole Stack Exchange site devoted to Wordpress at wordpress.stackexchange.com.
This is basically the same question:
https://wordpress.stackexchange.com/questions/11149/htaccess-disable-wordpress-rewrite-rules-for-folder-and-its-contents
On a site I'm working on the main portion of the site is wordpress powered.
I've added another directory completely separate from the wordpress site called employees and I'm having a little issue with the mod_rewrites for the new directory.
obviously wordpress uses this code to make its pretty urls
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
# END WordPress
but I want to add this rule as well and any other necessary rules or conditions so that all of the /name.php files in the employees directory get redirected to just /name
RewriteRule ^employees/(.*)$ employees/$1.php [L,QSA]
The several things I've tried all just cause employees/main to 404 but employees/main.php resolves properly.
I installed wordpress in a subdirectory, lets say www.example.com/wordpress. I want the user to hit www.example.com and see the index of www.example.com/wordpress. I'm already using a custom pretty permalinks structure /%category%/%pagename%/ so the htaccess file is a little foreign to me.
My current htaccess file looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
I've tried numerous solutions from browsing across the web but nothing seems to work. I either get internal 500 errors or view previous pages in the root directory like example.com/about (even though I've deleted the original about.html in the root) even after I deleted my cache.
Any help you could give would be extremely helpful. Thanks for your time,
Rob
The .htaccess file needs to be located in / and not in /wordpress/ and RewriteBase should be / not /wordpress/. Leave the permalinks setup on, but don't use an .htaccess file in /wordpress/. You'll need to set the root directory in your wordpress install to / and setup redirects for /wordpress/wp-content/ and the other wordpress subdirs in /.htaccess so that requests to those directories are also forwarded correctly.
I assume that you want to set up wordpress this way because there are other directories not associated with the wordpress install that you want to be accessible from / (www.example.com/cgi-bin/ for example). You'll need to set up your .htaccess file in / to make any directory aliases (like /cgi-bin/) accessible so requests to /cgi-bin/ don't get redirected to wordpress.
EDIT:
I haven't done something like this in a long time, but here's my best guess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/(.*)$ /wordpress/wp-content/$1 [L,QSA]
RewriteRule ^wp-admin/(.*)$ /wordpress/wp-admin/$1 [L,QSA]
RewriteRule ^wp-include/(.*)$ /wordpress/wp-include/$1 [L,QSA]
RewriteCond %{REQUEST_URI} !^/yourAliasUnrelatedToWordpress [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L,QSA]
</IfModule>