首页加载但其他返回共享主机上的500内部服务器错误

时间:2017-05-03 22:34:41

标签: php laravel .htaccess routes hosting

我使用ftp将我的laravel 4.2网站部署在共享主机上但路由无效。前端页面加载正常,但当我尝试转到另一个页面时,它返回“500内部服务器错误”。 :它正在读取.htaccess文件,但我不知道它是否正确。它是从laravel自动生成的。我上传了它。我也试过给存储和引导程序文件夹写入权限,但它仍然无效。

编辑:我发现了一些有趣的东西。如果我去www.example.com/test返回500内部错误但是如果我去www.example.com/index.php/test,现在它正确加载。知道怎么解决吗?

Edit2:它的工作原理。我只需要使用以下命令从网址中排除index.php:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

.htaccess文件

<IfModule mod_rewrite.c>
    <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]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

更新了解决问题的.htaccess文件

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

0 个答案:

没有答案
相关问题