Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My 404 .htaccess works very well when I put a wrong extension at it in place of .php.

Unfortunately the 404 does not work when I put a wrong name with .php.

This is my .htaccess code:

<Files ~ "^.(htaccess|htpasswd)$">
deny from all
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]

ErrorDocument 404 /404/notfound.html
order deny,allow
share|improve this question

migrated from stackoverflow.com Aug 10 '11 at 5:48

This question came from our site for professional and enthusiast programmers.

What do you see when you specify wrong url, that ends with .php? – zerkms Aug 9 '11 at 23:07
let me show u my links [link]s376762308.websitehome.co.uk/contactus.php this does not appear 404 file it is fine when eextenstion wrong [link]s376762308.websitehome.co.uk/contactus.html – maanu Aug 9 '11 at 23:14
Have you contacted to the support? – zerkms Aug 9 '11 at 23:21
@zerkms you mean with service provider – maanu Aug 9 '11 at 23:25
yep. Your .htaccess looks fine and works well for me. Seems like it is some specific webserver option specified on that server – zerkms Aug 9 '11 at 23:30

This is probably because all PHP requests are being sent to the PHP interpreter. I have seen this before on certain setups, normally with optimized PHP, specially configured FastCGI, etc.

What hosting platform are you on? Is it a linux host? You mention Apache. Do you have control over the server? What does php.ini look like?

Are you still having this issue? The links in your post look the same to me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.