Laravel 5.2 .htaccess和500内部错误

时间:2016-05-31 13:06:48

标签: php apache .htaccess laravel centos

我已在Host上部署了Laravel 5.2项目。

该项目在本地工作正常,但由于500 Internal Server Error文件我在Host上部署它时出现.htaccess错误!

这是我的.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>

P.S:

安装并启用了Laravel所需的PHP扩展。 我还授予775 storage权限,但没有任何变更!

任何帮助都会非常感激。

3 个答案:

答案 0 :(得分:0)

通过检查服务器配置文件中的AllowOverride指令,确保您有权在该文件夹中使用 .htaccess 文件。 (通常 httpd.ini )。

完整指南:https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

检查php.ini文件中是否安装并启用了mod_rewrite。 以下是如何在apache中安装/启用mod_rewrite的基本说明:https://stackoverflow.com/a/5758551/3435728

编辑:

确保您已在 .htaccess 文件中阅读了权限

答案 1 :(得分:0)

可能不支持MultiViews选项

<IfModule mod_rewrite.c>

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}]

答案 2 :(得分:0)

尽可能多地遵循以下步骤。

1. connect to hosting via SSH

2. install composer

3. in cpanel open Select PHP version and choose 5.4. (I also set phar extension)

4. install laravel: php composer.phar create-project laravel/laravel myproject --prefer-dist

5. copy everything from myproject/public to public_html

6. open public_html/index.php and set:

7. require __DIR__.'/../myproject/bootstrap/autoload.php';

8. $app = require_once __DIR__.'/../myproject/bootstrap/start.php';

对于7和8步,给出源所在的路径,以便文件找到该文件

希望这是有效的。

相关问题