views:

403

answers:

1

I have a relatively complex .htaccess file to control page requests, this currently redirects all requests of files (with some type exclusions) to an index file, with an exception of one directory that includes a WordPress installation.

I now need to enable the WordPress PermaLink support but I'm having some difficulty modifying the .htaccess to work.

The PermaLinks are required to produce more-SEO friendly URLs, and they are normally taken care of exclusively by WordPress - but it my case, it appears that a mod-rewrite rule, as detailed here is required (otherwise, when enabled it gives a 404 response).

Here is the current .htaccess contents:

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 commented out section is where I'm trying and failing to add a rule for the WordPress PermaLink functionality.

Initially, I thought this code was working but in fact some non-WordPress requests are still routed to the blog/index.php file and when trying to follow links out of the blog to other site areas these are again being routed back to the blog index.php.

+2  A: 

Well, I believe I've fixed this now - and the answer in hindsight is glaringly obvious. I've created another .htaccess file in the /blog/ directory and placed the relevant rules in there - seems to work perfectly.

BrynJ
that is the best way of doing it!
Jan Hancic