Forum Moderators: phranque
I am trying strip the .php extension of my URLs with the following .htaccess code:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI}!/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
I've uploaded the .htaccess file to the root of my web server (/html/) but I'm getting 403 errors on all my pages. I'm certain the mod_rewrite module is installed and working on the server, so what's going wrong? Is it the code? Folder/file permissions?
Any help would be greatly appreciated.
Thanks
Welcome to WebmasterWorld!
Check your server error log -- It will often tell you what's wrong.
Assuming that you've got the required spaces between "!" and the preceding non-blank character, I don't see anything wrong with your code (unfortunately, this forum deletes those spaces wehn you post). And if your code was defective, you'd be getting 500-Server Errors or 404-Not Found errors.
Jim
The code is still not working for me and I don't have access to the error logs. So, is there another way to write the code to hide the .php extension from the user's URL? Or is there some configuration files on the server that needs changing in order to get it to work?
Thanks again.