in /www/
I have an .htaccess
file containing:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^.]*\.less)$ compilers/lessphp.php?file=$1 [R,QSA,L]
</ifModule>
This code works fine, until I’m requesting .less files in /www/blog/
, where WordPress is located, and has its own .htaccess
file which contains the standard pretty permalinks mod_rewrite:
<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>
If I move WordPress’s mod_rewrite code to the root, and place it before my own mod_rewrite, everything works as expected:
# 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
# BEGIN LESSPHP
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^.]*\.less)$ compilers/lessphp.php?file=$1 [R,QSA,L]
</ifModule>
# END LESSPHP
The annoyance here, is any modification in WordPress to do with permalinks means I need to remember to cut the .htaccess
code from /www/blog/
and move it to the root.
Is there any way I can improve upon my mod_rewrite so WordPress isn’t overwriting it, and I can just leave everything where it is naturally placed? I would also rather not need to have two instances of my rule in both root and after WordPress’s. Also, WordPress’s mod_rewrite rules should be altered, since updating permalink settings will simply overwrite them.