鍍金池/ 問答/Linux/ nginx 配置增加了try_files后,默認(rèn)首頁就找不到了

nginx 配置增加了try_files后,默認(rèn)首頁就找不到了

nginx 配置增加了try_files $uri $uri.php$is_args$args;一行后,直接訪問域名就報錯誤403 Forbidden,去掉這行才可以,我要保留try_files的配置,請問該如何修改?

server
    {
        listen 80;
        server_name www.aaa.com;
        index index.html index.htm index.php default.html default.htm;
        root  /home/wwwroot/app_htx;

        include none.conf;
        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /\.
        {
            deny all;
        }

        location / {
                try_files $uri $uri.php$is_args$args;
        }

        access_log  /home/wwwlogs/access.log;
    }

目前估計是去找.php這個文件了,沒有找到就報錯了,如何修改配置,判斷url只有域名或者目錄情況就不執(zhí)行該配置

回答
編輯回答
絯孑氣
2018年8月24日 20:09
編輯回答
誮惜顏

試試再增加一個location

 location =/ {
                # just keep empty location
 }
2018年2月24日 22:18
編輯回答
夢一場

配置php的try_files,不能加上$is_args和$args等變量
因為nginx會加上這些字符來查找文件

這些變量應(yīng)該通過fastcgi的環(huán)境變量來傳遞

2018年4月15日 18:00