[PATCH] Honor the redirect response overwritten in error_page for absolute urls

Maxim Dounin mdounin at mdounin.ru
Thu Jan 10 16:55:16 UTC 2013


On Thu, Jan 10, 2013 at 11:57:58PM +0800, lanshun zhou wrote:

> Yeah, this will break current supported configs like the one you provided.
> But only
> the ones with 30x response code overwritten and without named location are
> affected. I think =30x in error_page is something like the "redirect" flag
> in "rewrite",
> which means "I want the redirect" by default.

No, =NNN means "I want NNN code to be returned", nothing more.  It 
allows to overwrite code returned if redirect is requested (via 
something like "http://..." set in uri parameter), but it doesn't 
request redirect by itself.

> I could think of these kinds of configs broken before the patch, and
> just not sure
> why introducing a location for 30x response.  Is the content
> for 30x response
> valuable? or to generate the "Location" header dynamically which can not be
> expressed by the url param with variables supported?

Some time ago returning correct content (more specifically, 
correct type of content) in redirections was required for WAP 
phones to handle them.

> But this patch does break supported configs, although named locations
> can be used
> instead as before to do anything. I just don't l like introducing a
> location to redirect
> for 404 error_page :)
> error_page 404 @notfound;
> location @notfound {
>     return 302 /error.html;  # or rewrite ^ /error.html redirect;
> }

Use something like this instead:

   error_page 404 http://example.com/error.html;

Maxim Dounin

More information about the nginx-devel mailing list