Nginx Url重写
2019-10-13 作者  Winter    服务器    阅读量1076    评论量0

实现 http://127.0.0.1/$URI   重写为  http://127.0.0.1/chrome/$URI

1、配置文件代码:

server {

        root /usr/share/nginx/www;

        index index.php index.html index.htm;

        listen 80;

        server_name localhost;


        location / {

            #如果是火狐浏览器访问

           if ($http_user_agent ~* 'firefox') {

              rewrite ^(.*) /chrome/$1 last;

           }

        }


        location /chrome {

           root /usr/share/nginx/www;

           index index.html;

        }

        #错误日志

        error_log /usr/share/nginx/logs/error.log error;

}

2、目录结构

blob.png

3、访问结果

http://127.0.0.1/m   ===》http://127.0.0.1/chrome/m

blob.png

blob.png

4、 如果有什么问题,可以查看错误日志 tail -f /usr/share/nginx/logs error.log

blob.png


上一篇:awk 入门教程
下一篇:Nginx Url重写-server

0条评论
热门文章
热评文章
精品课程

¥小额赞助

联系我们

邮箱:chennengit@163.com

手机:13455295173(微信)

QQ:376926761