nginx的index指令有什麼作用?
PHP中文网
PHP中文网 2017-05-16 17:20:27
0
1
394
server {
        listen 80;
        server_name phpcms.me m.phpcms.me;
        root /mnt/hgfs/www/open/phpcms;
        charset utf-8;
        index index.html index.php;
        try_files $uri $uri/ @rewrite;
        location ~ \.php {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi.conf;
        }
        location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/;
        }
}

這個是我的nginx配置,網站根目錄下有一個qiantu目錄,裡面有靜態的內容頁,不存在文件index.html。
透過 phpcms.me/qiantu/index.html可以存取列表頁首頁,是走的@rewrite規則
但是透過 phpcms.me/qiantu/ 就是直接403 forbidden了,根本沒走@rewrite規則。
但是刪除根目錄下的qiantu目錄 訪問 phpcms.me/qiantu/ 又可以走@rewrite規則進行訪問了。
想問下怎樣保留根目錄下的qiantu目錄的同時,透過存取phpcms.me/qiantu/ 可以讓其透過location進行匹配而不是直接403 forbidden

這裡的qiantu目錄只是個例子 ,不是固定的,因此不能透過 location = /qiantu/ {} 進行匹配。

PHP中文网
PHP中文网

认证0级讲师

全部回覆(1)
为情所困

chmod下試試

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!