nginx laravel 配置rewrite
阿新 • • 發佈:2018-12-14
在nginx.conf的server中加入
location / { 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; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }