I am using mod_rewrite to hide file extension this code is working prefect but when i add slash at the end of url it’s show error 500 internal server error
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Please help me
This is because the slash is being grouped together in the
(.*)and then referenced by$1, so a request like:is getting rewritten to:
The reason is that the condition
%{REQUEST_FILENAME}\.phpexists, because the trailing slash gets ignored. You just need to include the match against the trailing slash in yourRewriteRule‘s regex: