1 回答

TA貢獻(xiàn)1880條經(jīng)驗(yàn) 獲得超4個(gè)贊
Apache
Laravel 框架通過(guò) public/.htaccess 文件來(lái)讓 URL 不需要 index.php 即可訪(fǎng)問(wèn)。在 Apache 啟用 Laravel 之前,請(qǐng)確認(rèn)是否有開(kāi)啟 mod_rewrite 模塊,以便 .htaccess 文件發(fā)揮作用。
如果 Laravel 附帶的 .htaccess 文件在 Apache 中無(wú)法使用的話(huà),請(qǐng)嘗試下方的做法:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Nginx
如果你使用 Nginx ,在你的網(wǎng)站配置中加入下述代碼將會(huì)轉(zhuǎn)發(fā)所有的請(qǐng)求到 index.php 前端控制器。
location / {
try_files $uri $uri/ /index.php?$query_string;
}
- 1 回答
- 0 關(guān)注
- 3158 瀏覽
添加回答
舉報(bào)