I have this rule which redirects all requests without a .
in them to index.php
, and it works fine:
# Redirect all page requests to content handler
RewriteRule ^([^.]*)$ index.php [L]
Now I'd also like to disallow any requests where the original URL contains .php
in it. When I add another rule like this (after the first one), the first rule breaks:
# Disallow access to PHP files
RewriteRule \.php 404.php [L]
I thought that adding [L]
to the first rule would stop the second rule from being executed, but it seems to have no effect: the output from the first rule (i.e. index.php
) matches the second rule and all requests end up in 404.php
. What am I doing wrong here?