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

鍍金池/ 問(wèn)答/PHP  Linux  HTML/ laravel nginx 下配置 https 訪問(wèn)路徑問(wèn)題

laravel nginx 下配置 https 訪問(wèn)路徑問(wèn)題

求助, nginx 開(kāi)啟 https 下配置 xx.conf 路徑問(wèn)題
一下是 xx.conf 文件中的 location短

location / {
   index index.html index.htm index.php default.html default.htm default.php forum.php;
   
   #root /home/wwwroot/default/laravel/public;

   try_files $uri $uri/ /index.php?$query_string;
   if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=$1  last;
        break;
   }

}
問(wèn)題: root /home/wwwroot/default/laravel/public這一段被放開(kāi),會(huì)出現(xiàn)404的報(bào)錯(cuò),訪問(wèn)不到 laravel/public里的index.php 但是可以訪問(wèn)到.html的文件

但是如果 root /home/wwwroot/default/laravel/public這一段被注釋, nginx會(huì)自動(dòng)訪問(wèn)到nginx/html目錄。訪問(wèn)正常, index.php index.html均可訪問(wèn)

請(qǐng)問(wèn)如何才能正常訪問(wèn)到 /home/wwwroot/default/laravel/public 里的php文件

回答
編輯回答
安若晴

放出 Laravel5.5 的 nginx 官方推薦配置,其中加上了 https 跳轉(zhuǎn)的代碼,但是 SSL 的其他配置,請(qǐng)自行添加。

server {
    listen 80;
    server_name example.com;
    root /example.com/public;

    add_header X-Frame-Options "SAMEORIGIN";   
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php;

    charset utf-8;
    
    if ($ssl_protocol = "") { return 301 https://$server_name$request_uri; }
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }  
    location = /robots.txt  { access_log off; log_not_found off; }  

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Laravel 5.5 官方推薦 Nginx 配置學(xué)習(xí)

2017年5月29日 22:16
編輯回答
下墜

還有個(gè)前提,http 怎么都行,就https不行

2017年4月13日 23:12