Reputation: 311
i have a .htacces file containing
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?action=$1 [QSA,L]
it suits my need well. Accidentaly once i erased out the filename condiion like so
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?action=$1 [QSA,L]
to my ill understanding apache grabed the default file (index.html or index.php depending on setup) and inserted that into the action varible can someone plese explain to my how that works as its clearly not the route taken when the line is present.
Upvotes: 0
Views: 98
Reputation: 143886
The reason is because the -f
checks if the request file exists. On top of that, the rewrite engine will loop through all the rules until the URI stops changing. That means the first time around, say you have the request URI: /foo/bar
^(.*)
index.php?action=foo/bar
next time around, the URI is /index.php
^(.*)
index.php?action=index.php
next time around, it doesn't change so rewriting stops.
Upvotes: 1