laravel基本重寫規則
location / { index index.html index.htm index.php; try_files $uri $uri/ /index.php?$query_string ; }
去除末尾的斜杠,SEO更加友好
if (!-d $request_filename){ rewrite ^/(.+)/$ /$1 permanent;}
去除index action
if ($request_uri ~* index/?$){ rewrite ^/(.*)/index/?$ /$1 permanent;}
根據laravel規則進行url重寫
if (!-e $request_filename){ rewrite ^/(.*)$ /index.php?/$1 last; break;}
錯誤信息跳轉頁面必須在location ~ /.php(.*)${}
里面加入條:fastcgi_intercept_errors on開啟錯誤檢測信息
#nginx錯誤信息跳轉自定義頁面50x.html自己隨便定義
error_page 404 500 502 503 504 error.html;location = error.html { root html;}
root是error文件的根目錄
總結
以上所述是小編給大家介紹的Laravel的Nginx重寫規則實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!
新聞熱點
疑難解答