Reputation: 784
I have a simple 404 error redirect in the .htaccess to my script like this:
ErrorDocument 404 https://example.com/error.pl?q=404
But on the redirect the address is changed in the address bar of the browser to this https://example.com/error.pl?q=404
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!
Upvotes: 1
Views: 594
Reputation: 18671
Use link without domain name:
ErrorDocument 404 /error.pl?q=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. https://httpd.apache.org/docs/2.4/en/mod/core.html#errordocument
Upvotes: 2