在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Linux/ nginx直接輸入url訪問純html頁面,報錯404 Not Found,或者

nginx直接輸入url訪問純html頁面,報錯404 Not Found,或者主頁面(index)刷新報錯

貌似apache也會這樣。

clipboard.png

nginx配置只改動了server
clipboard.png

這是linux下的目錄

user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;

    ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        server{
                listen  80      default_server;
                rewrite ^/(.*)  http://www.leisuremoment.com/$1 permanent;
                server_name www.leisuremoment.com;
                location / {
                        root    /var/www/html;
                        index   index.html index.htm;
                        try_files       $uri    $uri/   /var/www/html/index.html;
                }
                error_page      404     /404.html;
                        location = /40x.html{ }
                error_page 500 502 503 504 /50.html;
                        location = /50x.html{  }
        }


        include /etc/nginx/sites-enabled/*;
}

clipboard.png

個人網(wǎng)站,index頁面刷新沒有問題,但是進(jìn)入其他頁面刷新就gg了。
http://leisuremoment.com/

回答
編輯回答
拼未來

你把你的nginx配置信息貼出來,然后再把你訪問的url放出來,大家就可以分析出來問題在哪了

2018年2月1日 21:43
編輯回答
菊外人

配置里沒寫try_files吧?


更新

看了下配置,說下發(fā)現(xiàn)的幾個問題:

  1. rewrite ^/(.*) http://www.leisuremoment.com/$1 permanent;try_files不要一起用。后者就是解決(優(yōu)化)前者來的,一起用不亂套了?
  2. 關(guān)于try_files /var/www/html/index.html;這條,前邊已經(jīng)用root定位過根目錄了,后邊實(shí)際上出來的都是基于根目錄的指向,再多套完整路徑進(jìn)去就不對了。
  3. try_files還是先寫成try_files $uri $uri/ /index.html;
  4. 這段:

    error_page      404     /404.html;
    location = /40x.html{ }
    error_page 500 502 503 504 /50.html;
    location = /50x.html{  }

    下邊的倆location是空的,沒意義的建議直接刪掉。另外建議確認(rèn)下是不是真的有404.html50.html,沒有的話這兩句error_page也是可以刪掉的,直接讓系統(tǒng)顯示默認(rèn)的報錯就好。

  5. 建議去看下access.log,看下URI請求映射到系統(tǒng)內(nèi)是哪個路徑,大概就能清楚是哪里有錯了。
2017年12月2日 20:07
編輯回答
汐顏

首先查看web根目錄下index.html是否存在,其次查看nginx的conf.d

# 定義服務(wù)器默認(rèn)網(wǎng)站根目錄
root    /var/www/html;
location / {
    # 定義首頁索引文件的名稱
    index  index.html index.htm;
}
2017年10月19日 03:54