location / {
if (!-e $request_filename)
{
rewrite "^/index\.html" /index.php last;
rewrite "^/category$" /index.php last;
rewrite "^/blog/([0-9]+)\.html" /blog/index\.php\?p=$1 last;
rewrite "^/aaa/([0-9]+)\.html" /aaa/index\.php\?p=$1 last;
break;
}
 }
http://www.xx.com/blog/10.html  //404
http://www.xx.com/aaa/10.html   //404
凡是在二级目录里的重写都是404, 根目录下正常。我看LOG文件记录又是302记录。location /blog/ {
}
这样写的时候不知道为什么直接重写到首页去了。重启NGINX IS OK成功的。请教下。谢谢。

解决方案 »

  1.   

    凡是在二级目录里的重写都是404意味着链接指向的网页不存在,/blog/index.php?p=xxx  确认可以访问么
      

  2.   


    单独index.php?p=xxx 可以正常访问的。
      

  3.   

    错误原来在这。rewrite "^/aaa/([0-9]+)\.html" /aaa/index\.php\?p=$1 last;/aaa/index.php?p=$1 last; 后面不用注释。。汗。
      

  4.   

    正则判断下路径是否重写是则跳404
    if ($request_filename ~ 路径) {
    set $error_html http://www.xx.com/blog/$1;

    error_page 404 $error_html;思路时这样