Forum Moderators: phranque
I'm setting up a 404 redirect on a Linux server and have this line in .htaccess:
ErrorDocument 404 /404handler.php
That works fine EXCEPT when the nonexistent page that's called for has the extension .html -AND- there is subfolder involved.
In other words, the redirect works for all these examples:
http://www.example.com/DoesNotExist.htm
http://www.example.com/DoesNotExist.php
http://www.example.com/DoesNotExist.asp
http://www.example.com/DoesNotExist.html
http://www.example.com/BadFolder
http://www.example.com/BadFolder/DoesNotExist.htm
http://www.example.com/BadFolder/DoesNotExist.php
http://www.example.com/BadFolder/DoesNotExist.asp
But in this case:
http://www.example.com/BadFolder/DoesNotExist.html
There is no redirection and the browser just opens at the home page of http://www.example.com.
My Web development experience is with WinServers and ASP and I'm only just trying to get a grip on Linux and php, so I guess I must be missing something.
Please tell me what it is.
[edited by: encyclo at 1:57 am (utc) on Feb. 10, 2008]
[edit reason] switched to example.com [/edit]
I don't like to call it a redirect, because the URL shown in the URL bar does not change. A redirect would also return a 301, 302, or 307 HTTP status code.
In reality, it is a special type of rewrite; one that also forces the HTTP header to return a 404 status code.
Threads about RedirectMatch [google.com]
If no root cause can be found and no real correction is possible, then of course any available work-around should be applied, so as to allow time to find a new hosting company. -- One that does not subject their customers to anomalous server behaviours. :)
Jim