Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a catchall .htaccess directive like this:

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L]

Anything that doesn't exist and the url is rewritten back to the index page. This is fine, however I want the header to be sent a 404 instead of a 200. How would I do this?

share|improve this question
1  
Redirect and rewrite are two different things. Your question and title don't match. – tugberk Dec 1 '11 at 20:28

1 Answer

I think the only way to do so is using ErrorDocument directive:

ErrorDocument 404 index.php

because with RewriteRule you are "masking" the error serving another page to the request.

Yet you must know that ErrorDocument 404 won't change the url of the page, thus you will have your homepage on a wrong url.

share|improve this answer
I had to use /index.php instead of index.php but that worked. That makes more sense now. Thanks – Jakobud Dec 1 '11 at 20:48

Your Answer

 
discard

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.