zoukankan      html  css  js  c++  java
  • nginx root 和alias

    root:
    
    
    192.168.137.1 - - [23/Jun/2020:09:40:07 +0800] "GET /index.html HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" "/var/www/html/index.html"
    
    192.168.137.1 - - [23/Jun/2020:09:44:27 +0800] "GET /index.html HTTP/1.1" 200 8 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" "/var/www/html/index.html"
    
    
    
    
    server{
            listen       8090;
            server_name  localhost;
            #ssl on;
            #从腾讯云获取到的第一个文件的全路径
            #ssl_certificate /etc/ssl/server.pem;
            #ssl_certificate_key /etc/ssl/server.key;
           location /staic  {
                gzip on;
                alias /var/www/html/;
                index  index.html index.htm;
            }
    }
    
    
    访问:
    
    http://192.168.137.3:8090/static/
    
    192.168.137.1 - - [23/Jun/2020:09:52:02 +0800] "GET /static/ HTTP/1.1" 200 13 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" "/var/www/html/static/index.html"
    
    
    如果改成root呢?
    
    server{
            listen       8090;
            server_name  localhost;
            #ssl on;
            #从腾讯云获取到的第一个文件的全路径
            #ssl_certificate /etc/ssl/server.pem;
            #ssl_certificate_key /etc/ssl/server.key;
           location /staic  {
                gzip on;
                root /var/www/html/;
                index  index.html index.htm;
            }
    }
    
    报错:
    
    192.168.137.1 - - [23/Jun/2020:09:54:27 +0800] "GET /static/ HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" "/usr/local/nginx/html/static/"
    
    
    192.168.137.1 - - [23/Jun/2020:10:01:27 +0800] "GET /static/ HTTP/1.1" 404 188 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" 
    
    "/var/www/html/static/static/"
    
    
    正确;
    root:
    
    server{
            listen       8090;
            server_name  localhost;
            #ssl on;
            #从腾讯云获取到的第一个文件的全路径
            #ssl_certificate /etc/ssl/server.pem;
            #ssl_certificate_key /etc/ssl/server.key;
           location /  {
                gzip on;
                root /var/www/html/;
                index  index.html index.htm;
            }
    }
    
    
    alias:
    server{
            listen       8090;
            server_name  localhost;
            #ssl on;
            #从腾讯云获取到的第一个文件的全路径
            #ssl_certificate /etc/ssl/server.pem;
            #ssl_certificate_key /etc/ssl/server.key;
           location /staic  {
                gzip on;
                alias /var/www/html/;
                index  index.html index.htm;
            }
    }
    
    
    Connection: keep-alive
    Content-Encoding: gzip
    
    
  • 相关阅读:
    Bullet 学习笔记之 btPersistentManifold 及 btManifoldPoint
    Bullet 学习笔记之 btCollisionWorld::performDiscreteCollisionDetection
    Bullet 学习笔记之 btCollisionWorld
    hdu 6617
    codeforces 1247 E
    GYM 101174 A
    GYM 100714 G
    codeforces 1239 C
    牛客挑战赛33D
    codeforces 1238 E
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348311.html
Copyright © 2011-2022 走看看