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成功的。请教下。谢谢。
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成功的。请教下。谢谢。
单独index.php?p=xxx 可以正常访问的。
if ($request_filename ~ 路径) {
set $error_html http://www.xx.com/blog/$1;
}
error_page 404 $error_html;思路时这样