I have this htaccess script
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /$1.php [L,QSA]
So i can get access a page like example.com/test but when i try to go to example.com/test/ it throws a 500 error. Can someone tell me what needs to change for it to work? Probably a stupid error.
Change pattern from
^(.+)$to one that will handle trailing slash separately:^(.*[^/])/?$This will work for both
/testand/test/— both will be rewritten to/test.php.If you want different behaviour, to have
/testworking but have “404 Not Found” error for/test/(instead of stupid “500 Server-side” error) you can use this:The rule above will check if target file exists BEFORE making rewrite .. so if
/test.phpdoes not exist, no rewrite will occur.