之前直接使用别人改写过的一个规则,一直没有注意,有好几个地方都是错误。搜索、分类什么的都无法使用。

唉!只有自己操刀改写一遍。服务器也不给力,半天搞不起,最终发现有地方引号问题。

rewrite
rewrite "^/date/([0-9]{6})/([0-9]{1,2})/page/([0-9]+)?/?$" /index.php?action=article&setdate=$1&setday=$2&page=$3 last;
rewrite "^/date/([0-9]{6})/([0-9]{1,2})/?$" /index.php?action=article&setdate=$1&setday=$2 last;
rewrite "^/date/([0-9]{6})/page/([0-9]+)?/?$" /index.php?action=article&setdate=$1&page=$2 last;
rewrite "^/date/([0-9]{6})/?$" /index.php?action=article&setdate=$1 last;
rewrite "^/page/([0-9]+)?/?$" /index.php?action=article&page=$1 last;
rewrite "^/category/([0-9]+)/?([0-9]+)?/?$" /index.php?action=article&cid=$1&page=$2 last;
rewrite "^/category/([^/]+)/?([0-9]+)?/?$" /index.php?action=article&curl=$1&page=$2 last;
rewrite "^/(archives|list|article|links)/?$" /index.php?action=$1 last;
rewrite "^/(comments|tagslist|article)/?([0-9]+)?/?$" /index.php?action=$1&page=$2 last;
rewrite "^/search/([0-9]+)/?([0-9]+)?/?$" /index.php?action=article&searchid=$1&page=$2 last;
rewrite "^/tag/([^/]+)/?([0-9]+)?/?$" /index.php?action=article&tag=$1&page=$2 last;
rewrite "^/archives/([0-9]+)/?([0-9]+)?/?$" /index.php?action=show&id=$1&page=$2 last;
rewrite "^/rss/([0-9]+)?/?$" /rss.php?cid=$1 last;
rewrite "^/rss/([^/]+)/?$" /rss.php?url=$1 last;
rewrite "^/uid/([0-9]+)/?([0-9]+)?/?$" /index.php?action=article&uid=$1&page=$2 last;
rewrite "^/user/([^/]+)/?([0-9]+)?/?$" /index.php?action=article&user=$1&page=$2 last;
rewrite sitemap.xml sitemap.php last;
rewrite "^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$" $1/index.php?action=show&alias=$2&page=$3 last;

记录一下,备查。适用于nginx

标签: nginx, rewrite, 伪静态

评论已关闭