4.Nginx 的 location 与 root

7./etc/nginx/conf.d/default.conf 配置文件:

    server {
        listen       80;
        server_name  www.zipeiyi.corp;

        location / {                            #代表在浏览器直接输入www.zipeiyi.com
            root   /usr/share/nginx/html;       #去找这个绝对路径目录下的index.html 
            index  index.html index.htm;
        }


        location /app.html {                  #代表访问www.zipeiyi.corp/app.html 
            root   html;                      #去找这个路径下的index.html 
            index  index.html index.htm;      #代表nginx安装目录下的html文件夹,比如说你nginx安装在了/opt/nginx 下,那么html代表的目录就为 /opt/nginx/html 
但是如果你写 root  /html   ,那就不是相对路径了(nginx安装目录下),那就是/html了  
        }

        error_page   500 502 503 504  /50x.html;    #定义的返回错误状态码是500 502的,统一跳转到50x.html这个页面
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

       
    }
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容