nginx location 301
If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, scgi_pass, uwsgi_pass, or memcached_pass, then in response to a request with URI equal to this string, but without the trailing slash, a permanent redirect with the code 301 will be returned to the requested URI with the slash appended. If this is not desired, an exact match of
the URI and location could be defined like this:
location /user/ {
proxy_pass http://user.example.com;
}
location = /user {
proxy_pass http://login.example.com;
}
如果location包含proxy_pass, fastcgi_pass, scgi_pass, uwsgi_pass, or memcached_pass可以通过如上指令解决,如果是普通的只能通过重定向后到php去处理返回header来301了,上面的是不起作用,不带斜线的都会301到带斜线的
2013/12/13 15:52:59 [notice] 11109#0: *179384 "^/goto.html$" does not match "/jx", client: 124.42.13.230, server: www.redis.com.cn, request: "GET /jx HTTP/1.1", host: "www.redis.com.cn"
2013/12/13 15:53:02 [notice] 11109#0: *179385 "^/jx/([d]+).html$" does not match "/jx/", client: 124.42.13.230, server: www.redis.com.cn, request: "GET /jx/ HTTP/1.1", host: "www.redis.com.cn"
2013/12/13 15:53:02 [notice] 11109#0: *179385 "^/jx/([d]+).html$" does not match "/jx/index.html", client: 124.42.13.230, server: www.redis.com.cn, request: "GET /jx/ HTTP/1.1", host: "www.redis.com.cn"
访问http://www.redis.com.cn/jx会自动301跳转到http://www.redis.com.cn/jx/
参考:
http://nginx.org/en/docs/http/ngx_http_core_module.html