Arsenii Arsenii - 9 months ago 55
Apache Configuration Question

How to keep URI in the browser using ErrorDocument in .htaccess?

I have a simple 404 error redirect in the .htaccess to my script like this:

ErrorDocument 404

But on the redirect the address is changed in the address bar of the browser to this
from the wrong address (from which the redirect is performed).

How to keep the initial address in the browser address bar while redirecting to the custom error page?

Your kind help is highly appreciated!


Use link without domain name:

ErrorDocument 404 /

Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache HTTP Server will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code.