Currently I got this in my .htaccess file to remove .php from the url's of my website RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php Code (markup): So lets say I go to a webpage like www.mydomain.com/support, it will take me to support.php But if I go to a webpage like www.mydomain.com/support/ , it will give me a Error 500: Internal Server Error How come when I add a / at the end of the website, it gives me a 500 error?
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)(\/)?$ $1.php Code (markup):
The reason it does it is because by putting a / at the end you are saying it is a folder, so it looks for the folder called support and doesn't find it.
You can write another rule to redirect from trailing slash to non trailing slash. This should resolve the issue. Take this example but follow the reverse technique... http://www.mydigitallife.info/add-trailing-slash-to-the-end-of-the-url-with-htaccess-rewrite-rules/
Hi haddad, RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^\/]+)(\/)*$ $1.php
I tried that, it just took me to the 500 error page, and the link became mydomain.com/support/.php.php/.php/