Reputation: 905
I have the following in a htaccess file to rewrite the params out
RewriteRule ^(.*)$ index.php?unique=$1 [L,QSA]
Now the issue I have is with recursion
/folder/12345
- works fine and gets the value 12345
/folder/sub-folder/
- the index.php*strong text* file in here breaks with the above script
Anyone ideas how to stop it filtering into sub folder's index.php files?
Upvotes: 1
Views: 528
Reputation: 30061
You should be able to use a simple condition to check so the requested url isn't pointing to a file:
RewriteBase /folder/
# check so the request doesn't contain a valid filename
RewriteCond %{REQUEST_FILENAME} !-f
# bounce everything to index.php
RewriteRule ^(.*)$ index.php?unique=$1 [L,QSA]
The above will send everything that isn't a valid url to index.php
while urls containing a filename such as example.com/index.php
will be left untouched.
Upvotes: 2