一些目录或者文件如果真实存在就不遵守伪静态规则,这样的逻辑只需要做一个判断即可,代码如下:
if (!-e $request_filename) {
rewrite ^/(tag/.+|tag)/$ /tag.php?path=$1 last;rewrite ^/s/$ /search.php last;
rewrite ^/([a-zA-Z0-9/_]+)/$ /list.php?path=$1 last;
}
if (!-f $request_filename) {
rewrite ^/(tag/.+)/list_([0-9]+).html$ /tag.php?path=$1&p=$2 last;
rewrite ^/([a-zA-Z0-9/_]+)/list_([0-9]+).html$ /list.php?path=$1&p=$2 last;
rewrite ^/([a-zA-Z0-9/_]+)/([a-z0-9-_]+).html$ /content.php?path=$1/$2.html last;
rewrite ^/([a-zA-Z0-9-_]+).html$ /topic.php?path=$1 last;
rewrite ^/(sitemap|rss).xml$ /api/$1.xml.php last;
}
其中-e代码是文件夹,-f代表是文件。
还没有人来评论,快来抢个沙发吧!