【发布时间】:2013-07-20 12:39:11
【问题描述】:
我想摆脱这些工作规则
location = /contact {
rewrite ^(.*)$ /index.php?v=contact last; break;
}
location = /terms {
rewrite ^(.*)$ /index.php?v=terms last; break;
}
location = /faq {
rewrite ^(.*)$ /index.php?v=faq last; break;
}
location = /twitter {
rewrite ^(.*)$ /index.php?v2=twitter last; break;
}
location = /facebook {
rewrite ^(.*)$ /index.php?v2=facebook last; break;
}
location = /login {
rewrite ^(.*)$ /index.php?v2=login last; break;
}
location = /privacy {
rewrite ^(.*)$ /index.php?v=privacy last; break;
}
这样的事情
location / {
try_files $uri $uri/ =404;
rewrite ^/(contact|privacy|terms|faq)$ /index.php?v=$1 last;
rewrite ^/(twitter|facebook|login)$ /index.php?v2=$1 last; break;
}
但问题是“联系人”、“条款”、“隐私”、“推特”、“脸书”页面工作正常,但 “隐私”和“登录”页面抛出 404 错误.
没有其他涉及“登录”和“隐私”的重写规则
【问题讨论】:
-
建议打开调试日志找出两个404 url的踪迹。
-
@TroyCheng
open() "/usr/share/nginx/www/privacy" failed (2: No such file or directory)所以它根本不是重写 -
我的意思是当打开调试选项时,你可以在error_log中跟踪重写过程,这样你就可以知道它是如何重写的,哪里出错了。
标签: php nginx rewrite http-status-code-404