Rewrite URL with two different nested redirects (one for WordPress permalinks)
I have a relatively complex .htaccess file for managing page requests that currently redirects all file requests (with some type exceptions) to the index file except for one directory that includes the WordPress installation.
Now I need to enable WordPress PermaLink support, but I have some difficulty changing .htaccess to work.
PermaLinks are supposed to create more SEO-friendly URLs, and generally they only care about WordPress, but that's my case, it looks like the mod-rewrite rule as detailed here is required (otherwise it gives a 404 response when enabled ).
Here is the current content of the .htaccess:
RewriteEngine ON
RewriteCond %{HTTP_HOST} !^www\..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*)\.(co\.uk)
RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=permanent,L]
AddHandler application/x-httpd-php .phtml
#RewriteBase /blog/
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /blog/index.php [L]
RewriteBase /
RewriteRule ^blog/ - [L]
RewriteRule !\.(js|ico|gif|jpg|JPG|png|css|php|phtml|pdf|txt|xml|swf|flv)$ index.phtml
The enclosed section is where I am trying and unable to add a rule for WordPress PermaLink functions.
I originally thought this code was working, but actually some non-WordPress requests are still routed to blog / index.php, and when trying to follow links from the blog to other areas of the site, they are redirected to the index blog again .php.
source to share