D
D
d1KdaT2015-06-21 21:21:59
PHP
d1KdaT, 2015-06-21 21:21:59

Why doesn't header location work with error_page in nginx?

On my site, when there was still Apache, in .htaccess with a 404 error, index.php was loaded with a redirect to another site in the form:

header("Location: http://site.ru{$_SERVER['REQUEST_URI']}");

When moving to nginx, redirection simply stopped working.
PS In nginx I specified "error_page 404 /index.php;"
What's my mistake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-06-21
@d1KdaT

server {
        server_name  site1.ru;

        rewrite ^(.*) http://site2.ru/$1 permanent;
    }

server {
        server_name  www.site.ru;

        rewrite ^(.*) http://site.ru/$1 permanent;
    }

redirect 30x
error 40x it is
impossible to transmit two response codes at the same time
The fact that Apache allowed this does not mean that it is right to do so.
nginx doesn't allow you to do this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question