.htaccess ErrorDocument not working


I have a sub-domain setup that has the web directory pointing to another folder within the root folder of another domain.

dev.url.com technically points to www.url.com/_dev/

I have a .htaccess file in the _dev folder containing the following:

[code]AuthUserFile ###
AuthName "DEV"
AuthType Basic
require valid-user

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]

ErrorDocument 404 /404.php[/code]

The rewrite code works just fine.

But, if I go to a page that doesn’t exist, I get a 500 Internal Server Error.

I have tried to move the ErrorDoc line above the rewrite code, but that didn’t help.

I also tried it with the ErrorDoc reading like the following. Still get the 500 error.

My assumption is that I need to have the sub-domain pointing to it’s own folder instead of a sub-folder under a different domain.

Am I right?


I haven’t tried this to verify, and I do see that /404.php is one of the examples in the wiki, but I don’t think it will work.

try ./404.php
or just 404.php


I tried both without luck.[hr]
I pointed the sub-domain to isn’t own folder and the error is still happening.

I have a feeling it has to do with the rewrite code, but I can’t figure out exactly what part of it!

I can comment the rewrite code out and the ErrorDocument works just fine.


Got it to work with this line

instead of this line


There are two issues here. First, how is dev.url.com pointing to www.url.com/_dev? Have you set it as the document root in the panel? Created symlinks? Or what?

Second is that setting an 404 error document is not going to work because you are already directing any requests for non-existent files and directories to your index.php file. Your app should be handling 404 requests, not .htaccess. You may have found a way to avoid the 500 error (which is probably due to too many redirects, check your error log), but that doesn’t mean that your 404 document will work with those RewriteConds.