nginx $document_uri 防止死循环
2015-11-30 18:02
435 查看
$document_uri 表示访问的url
现在我的需求是,访问 www.xxx.com 请求到 www.xxx.com/bbs/
在nginx配置文件中加入
if ($document_uri !~ ‘bbs’)
{
rewrite ^/(.*)$ http://www.xxx.com/bbs/$1 permanent;
}
而不是单独加一句 rewrite ^/(.*)$ http://www.xxx.com/bbs/$1 permanent;
如果只加rewrite 规则,而不限定条件,那么会造成死循环。 会访问到 http://www.xxx.com/bbs/bbs/bbs/bbs/…
现在我的需求是,访问 www.xxx.com 请求到 www.xxx.com/bbs/
在nginx配置文件中加入
if ($document_uri !~ ‘bbs’)
{
rewrite ^/(.*)$ http://www.xxx.com/bbs/$1 permanent;
}
而不是单独加一句 rewrite ^/(.*)$ http://www.xxx.com/bbs/$1 permanent;
如果只加rewrite 规则,而不限定条件,那么会造成死循环。 会访问到 http://www.xxx.com/bbs/bbs/bbs/bbs/…
相关文章推荐
- 如何更改nginx网站根目录 以及解析php
- Nginx之location 匹配规则详解
- Web负载均衡高可用之Nginx+Keepalived
- CDN下nginx获取用户真实IP地址
- nginx的高级配置(2)——域名重定向
- nginx url rewrite之thinkphp示例
- nginx的高级配置(1)——为某个虚拟主机添加用户验证
- 从nginx获取css无法解析的问题
- Centos下安装nginx rpm包
- nginx安全
- nginx安全
- nginx js、css多个请求合并为一个请求(concat模块)
- nginx.conf配置文件的基本详解
- Nginx重写规则指南 转
- nginx做rails项目web服务器缓存配置方法
- Ubuntu下安装Nginx
- nginx服务配置---php服务接入
- Nginx和lvs在负载均衡方面的对比
- nginx php-fpm 输出php错误日志
- Nginx代码风格图示