WordPress: Permalink Rewrite Problem

#1
Hi

I'm hoping a LS guru can help me with this.

I'm running WordPress inside a site under the url: mysite.com/blog

Using the default permalinks, this works fine with the rewrite rule:

RewriteRule ^/blog(.*) /external/wordpress/$1 [NC,L]

But if I change the default permalink structure, the links produce a 404.

For some reason WordPress uses rewrites instead of simply parsing non-default request urls in the code :-(. So it generates a .htaccess in it's home directory which looks like this:

<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>

I can't get this to work, even if I enable symlinks and .htaccess in LS, and in any case for performance and security I'd prefer to put everything into my main rewrite rules in the config file.

Can anyone kindly give me any clues about how to adapt these rewrite rules so they work in the main config file? My mod_rewrite skills are a bit on the basic side...
 
#2
OK - I seem to have nailed this. Not fully tested, but working so far...

In case it's of use to anyone, it's a simple as this:

RewriteRule ^/blog/wp-includes/(.*) /external/wordpress/wp-includes/$1 [NC,L]
RewriteRule ^/blog/wp-content/(.*) /external/wordpress/wp-content/$1 [NC,L]
RewriteRule ^/blog/(.*) /external/wordpress/index.php [NC,L]
 
#3
Corrected version:

RewriteRule ^/blog/wp-includes/(.*) /external/wordpress/wp-includes/$1 [NC,L]
RewriteRule ^/blog/wp-content/(.*) /external/wordpress/wp-content/$1 [NC,L]
RewriteRule ^/blog/wp-admin/(.*) /external/wordpress/wp-admin/$1 [NC,L]
RewriteRule ^/blog/wp-login.php(.*) /external/wordpress/wp-login.php/$1 [NC,L]
RewriteRule ^/blog(.*) /external/wordpress/index.php [NC,L]
 
Last edited:
Top