Simon H
Simon H

Reputation: 374

.htaccess rewrite problems 404 error

I am using .htaccess to beautify my URLs. I use this code:

RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php

DirectoryIndex index.html index.htm index.php index.shtml index.shtm

ErrorDocument 404 /404

However when I go to any URL without the .php extension it gives me a 404 error:

/www/alltutories.comule.com/contact.php

But contact.php does exist on my server... I have no idea why this is happening.

Upvotes: 2

Views: 100

Answers (2)

DRC
DRC

Reputation: 5048

could you try something like, changing only this line:

RewriteRule ^(.+)$ $1.php [L,QSA]

Upvotes: 0

Goombi
Goombi

Reputation: 81

I think %{REQUEST_FILENAME} is "contact.php", so %{REQUEST_FILENAME}\\.php is "contact.php.php" which does not exists.

Upvotes: 1

Related Questions