laravel框架如何去掉URL中index.php
1 回答

慕村225694
TA貢獻1880條經驗 獲得超4個贊
Apache
Laravel 框架通過 public/.htaccess 文件來讓 URL 不需要 index.php 即可訪問。在 Apache 啟用 Laravel 之前,請確認是否有開啟 mod_rewrite 模塊,以便 .htaccess 文件發揮作用。
如果 Laravel 附帶的 .htaccess 文件在 Apache 中無法使用的話,請嘗試下方的做法:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Nginx
如果你使用 Nginx ,在你的網站配置中加入下述代碼將會轉發所有的請求到 index.php 前端控制器。
location / {
try_files $uri $uri/ /index.php?$query_string;
}
- 1 回答
- 0 關注
- 3135 瀏覽
添加回答
舉報
0/150
提交
取消