我的nginx重写规则有问题
我的第一条重写规则是:我的nginx重写规则有问题,nginx,Nginx,我的第一条重写规则是: location / { root E://w/q/__t/q/; index index.html index.htm; } 然后我请求127.0.0.1/test.js 我可以在fold E://w/q/\uu\t/q中获取test.js文件/ 然后更新重写规则,在我的位置和请求路径中添加/js/path: location /js/ { root E://w/q/__t/q/;
location / {
root E://w/q/__t/q/;
index index.html index.htm;
}
然后我请求127.0.0.1/test.js
我可以在fold E://w/q/\uu\t/q中获取test.js文件/
然后更新重写规则,在我的位置和请求路径中添加/js/path:
location /js/ {
root E://w/q/__t/q/;
index index.html index.htm;
}
然后我请求127.0.0.1/js/test.js
但是nginx返回404
那么我的代码怎么了?怎样才能使它正确
我的nginx版本是1.5.8,我的操作系统是windows7。好吧,你实际上没有使用rewrite命令 使用此配置,当您请求127.0.0.1/js/test.js时,Nginx将查看E://w/q/_t/q/js/test.js 因此,请将您的js复制到那里,或者使用重写命令删除url中的js部分。如果您没有更新根目录,您可以这样做,或者使用alias代替根目录
location /js/ {
root E://w/q/__t/q/js;
index index.html index.htm;
}
或
Ps:尽量避免放置位置和内部位置,这是一种不好的做法,而且如果要使用,请确保不要将try_文件与之一起使用我更改了标记,因为在这个问题上既没有JavaScript也没有Apache。旧的url仍然有效吗?你重新加载配置nginx-s了吗?@dystroy:我肯定我已经重新加载了
location /js/ {
alias E://w/q/__t/q/;
index index.html index.htm;
}