教程帮助

影视cms伪静态设置排除指定目录的设置方法

时间:2022-03-31 09:49:54   作者:jierai.com   来源:阿杰影视资源   阅读:149   评论:0
内容摘要:方案一、location~*^/(?![static|h5]){..伪静态规则}通过location~*^/(?![sys-static|h5])来设置排除目录,|分割多个目录。location~*^/(?![static|h5]){...伪静态规则}===========示例:location~*^/(?![stat...

方案一、

location ~* ^/(?![static|h5]) { .. 伪静态规则 }通过 location ~* ^/(?![sys-static|h5])  来设置排除目录,| 分割多个目录。

location ~* ^/(?![static|h5]) {

... 伪静态规则

}

===========

示例:

location ~* ^/(?![static|h5]) {

    rewrite ^(.*)/([0-9a-zA-Z]+)/$ $1/index.php?url=article/index&pathname=$2 last;

    rewrite ^(.*)/([0-9a-zA-Z]+)-([0-9]+).html$ $1/index.php?url=article/index&pathname=$2&page=$3 last;

}

这个排除了static和h5目录

注意:这个方法也不知道是不是我姿势不正确。实际测试有问题,location 中的伪静态规则只有第一个栏目规则和第一个栏目的文章规则执行正常,后面的均不正确。建议使用后面两种方案。

方案二、

所以有了第二种让nginx伪静态排除指定目录方案,使用多个 location,不再使用反向排除的思路,改用匹配到该规则,使用 break 语句停止 rewrite 检查。

location ~* /h5/|/sys-static/{

    break;

}

location ~* {
    ...
}

方案三、

还可以使用请求某个真实存在的文件跳出。示例:

location ~* {

    if (-f $request_filename) { 

        break; 

    }

    ...
}

出处:阿杰影视资源网
网址:
https://jierai.com
转载时请注明出处和网址 

标签:location  静态  规则  static  目录  
相关评论
如果本站侵犯了您的权益请邮件[email protected]     站长阿杰:79115960
  粤ICP备18135429号