nginx添加二级访问目录

实现以下效果:

http://127.0.0.1/home-web             // 官网

http://127.0.0.1/app-web               //  手机页面

http://127.0.0.1/admin-web           // 后台管理页面


server {

        listen      80;

        server_name  _;

       #默认主页

        location / {

            root  /opt/web/home-web/;

            index  index.html index.htm;

            try_files $uri $uri/ /index.html;

        }

       #location /home-web  中的 home-web 为网站访问路径

        location /home-web {                 

            alias  /opt/web/home-web/;     # 使用alias方式,home-web 后面必须跟 “/”

            index  index.html index.htm;

            try_files $uri $uri/ /index.html;

        }

        location /app-web {

            alias  /opt/web/app-web/;

            index  index.html index.htm;

            try_files $uri $uri/ /index.html;

        }

        location /admin-web {

            alias  /opt/web/admin-web/;

            index  index.html index.htm;

            try_files $uri $uri/ /index.html;

        }

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容