之前在配置nginx location时总是遇到301错误,百思不得其解,关键是我没有用rewrite,但是我用了alias,因此怀疑是alias引起了301错误。
alias /data/nginx/zzp/exact/;
alias /data/nginx/zzp/regex/;
alias /data/nginx/zzp/exact/;
location ~ ^/zzp/(.*\.html)$ {
alias /data/nginx/zzp/regex/$1;
If alias
is used inside a location defined with a regular expression then such regular expression should contain captures and alias
should refer to these captures (0.7.40) 上面的话来自nginx的文档,意思是,当nginx的location是一个正则表达式时,这个正则表达式应该包含capture,并且alias中要引用这些capture,也就是$1那个部分。
再深究为什么,在stackoverflow上面说是导致了内部重定向循环,但是没看懂。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29757574/viewspace-2147809/,如需转载,请注明出处,否则将追究法律责任。