Output redirect location into custom nginx error page

Viewed 19

I want to use custom error pages for redirects in nginx. The redirect location should be shown in the template.

This works well so far:

Nginx Config:

error_page 301 302 /error_redirect.html;
location = /error_redirect.html {
    ssi on;
    root /etc/nginx/templates;
}
location = /redirect_example.html {
   return 301 /redirect_target.html;
}

Template:

<html>
<head><title>This page has moved</title></head>
<body>
This page has moved.<br>
<a href="<!--# echo var=request_uri default="/" -->">Old URI</a>
</body>
</html>

The request_uri in the template shows the "old" request URI which I don't want to show.

I also tried uri but this is set to /error_redirect.html and not to /redirect_target.html.

How can I access the "redirect location" to echo the redirect target in my template?

0 Answers
Related