The following rule in my .htaccess
works just fine for routing calls to index.php
:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
However, this does not work when running on a temporary URL like http://example.com/~test/
.
In such a case, the .htaccess file needs to read:
RewriteEngine On
RewriteBase /~test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
Note the extra RewriteBase
.
Question: is it possible to write a rule in .htaccess to "detect" whether to apply that RewriteBase
?
The reason is the .htaccess if version controlled, and I'd like for it to work on multiple installations.