I have a website where various parts parse request URLs by themselves and some don't (e.g. a vBulletin forum). The .htaccess I have to send requests to the appropriates scripts is:
# wiki, shop, admin
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !(.*)\.js
RewriteRule ^wiki/(.*)$ w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ wiki/ [L,QSA]
RewriteRule ^shop/ /shop/shop.php [NC,L]
RewriteRule ^forum/admincp/pkr/ /forum/admincp/pkr/pkr.php [NC,L]
This doesn't work as I expected. I forgot that the rewrite conditions are only applied to the first rule that follows them. The question is How can I apply those RewriteConditions to all those rules without having to copypaste them 4 times?
What goes wrong is this:
- /shop/example is rewritten to /shop/shop.php
/shop/shop.php is then rewritten again to /shop/shop.php (read: we have an infinite loop). This would not happen if this condition was applied to that rewrite rule, because /shop/shop.php is an actual file:
RewriteCond %{REQUEST_FILENAME} !-f
So yeah...