Laravel路线.htaccess文件无法在1和1主机上运行


Laravel routes & .htaccess file not working on 1and1 hosting

我的客户最近购买了一个linux 1&1个来自1and1.com托管公司的无限套餐。我在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

RewriteBase /
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]