課程
/后端開發
/PHP
/輕松學會Laravel-基礎篇
設置路由名就無法訪問,出現404錯誤
2018-07-21
源自:輕松學會Laravel-基礎篇 3-1
正在回答
在nginx里加上如下rewrite代碼:
location / {
? ? ? ? try_files $uri $uri/ /index.php?$query_string;
? ? }
? ? 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;
舉報
Laravel框架基礎視頻教程,輕松入門,了解Laravel的優勢
1 回答wnmp配置laravel,路由訪問出錯。
2 回答路由訪問不了
1 回答路由別名的問題
3 回答路由的別名
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-07-23
在nginx里加上如下rewrite代碼:
location / {
? ? ? ? try_files $uri $uri/ /index.php?$query_string;
? ? }
? ? 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;
? ? ? }