Forum Moderators: phranque

Message Too Old, No Replies

Extensionless URL not working

.htaccess script for extensionless URLs not working

         

ch33ch

4:42 pm on Jan 3, 2006 (gmt 0)

10+ Year Member



Hi,

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

jdMorgan

8:10 pm on Jan 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ch33ch,

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

ch33ch

5:58 am on Jan 4, 2006 (gmt 0)

10+ Year Member



Thanks for your reply, 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.