T
T
Tesla2012-08-02 08:34:12
Apache HTTP Server
Tesla, 2012-08-02 08:34:12

How to get rid of redirect in .htaccess ErrorDocument?

There is a domain with a bunch of subdomains with a variety of engines, including self-written ones. For all subdomains, I want to make one page-handler for 404, 403 and other errors. I write in the .htaccess of each subdomain ErrorDocument 404 http://dev.domain/error/404
When sub1.domain/blabla is opened , a 302 redirect occurs to the dev.domain/error/404 page , which is not good at all.
Is it possible to get rid of the redirect by giving the user a handler page from another domain?
Or am I digging in the wrong direction at all, and is it done somehow differently?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Igor, 2012-08-02
@Tesla

a piece of my apache2.conf
Alias ​​/error/ "/home/hosting/ERROR_PAGES/"
<Directory "/home/hosting/ERROR_PAGES">
AllowOverride None
Options IncludesNoExec
Order allow,deny
Allow from all
/* here is a Directory close, but thanks to habraparser and limitations of using syntax highlighting with my karma for not being able to properly write the closing tag */
ErrorDocument 400 /error/error_400.html
ErrorDocument 401 /error/error_401.html
and by analogy everything else

I
Igor, 2012-08-02
@admhome

EMNIP can also simply write ErrorDocument directives in httpd.conf (apache2.conf) and not redirect to the domain, but give pages from one directory. When I had only apache2 (without nginx in front of it), then this is how I did it.

M
meefa, 2016-02-03
@meefa

Although more than three years have passed since the question was asked, the solution turned out to be very simple and I could not help but share.
You need to specify not an absolute path to a 404 page, but a relative one. In your case it should be
instead
of httpd.apache.org/docs/current/mod/core.html#errord...

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.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question