[英]Laravel routes & .htaccess file not working on 1and1 hosting
我的客戶最近從1and1.com托管公司購買了linux 1&1無限包。 我在Laravel 4.2框架中為他構建了應用程序。 該應用程序在我的本地計算機上以及在我自己的VPS上運行得非常好。 但是當我在客戶端主機上設置文件時,看起來.htaccess文件無效。 這就是為什么,laravel路由不起作用,我在嘗試訪問網站的不同路由時不斷收到404錯誤消息。
我已經對這個問題進行了很多研究,發現許多人都處於同樣的問題但卻找不到解決這個問題的真正方法。
這是.htaccess代碼:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我正在使用Laravel 4.2
我在我的1&1托管解決方案上遇到了同樣的問題。 我建議添加:
RewriteBase /
這對我有用。
一切順利,M
我使用Laravel 5.2,謝謝,它對我也有用,謝謝我在我的.htaccess文件中添加了RewriteBase
<IfModule mod_rewrite.c>
RewriteBase /
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
這對我.htaccess
,只是以下內容在我的.htaccess
RewriteBase /
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.