Overriding default 'missing trailing slash' behavior

Maxim Dounin mdounin at mdounin.ru
Thu Dec 24 19:55:15 MSK 2009


Hello!

On Thu, Dec 24, 2009 at 07:24:34AM -0900, Melvyn Sopacua wrote:

> Hi,
> 
> Is there a way to override the default behavior of how nginx handles directory 
> redirecting?
> At present is does the equivalent of:
> rewrite $scheme://$first_server_name/$request_uri/ permanent
> 
> I tried overriding:
> location = /software {
> 	root /path/to/webroot
> 	rewrite $scheme://$http_host/software/ redirect;

This is just incorrect rewrite, you probably mean 

	rewrite ^ $scheme://$http_host/software/ redirect;

instead.  But see below.

> }
> 
> But it doesn't even get there, as the log shows a 301 rather then a 302 with 
> the wrong host.
> This is a problem for me, as the same site should be accessible from within 
> and outside the network, using different hostnames. Two of these hostnames 
> don't exist outside the network.


server_name_in_redirect off;

http://wiki.nginx.org/NginxHttpCoreModule#server_name_in_redirect

Maxim Dounin



More information about the nginx mailing list