Hostgator上的Laravel 4内部服务器错误500

时间:2013-08-17 22:38:10

标签: .htaccess laravel laravel-4 internal-server-error

我在共享的Hostgator服务器上部署了一个Laravel 4应用程序。

当我导航到:

http://mydomain.com/laravel/public/

我可以看到Laravel启动画面。

但是当我尝试访问任何其他路线时,例如/ users或/ posts我正在

Internal Server Error 500

http://mydomain.com/laravel/public/posts

控制器:

public function index()
    {
        $posts = $this->post->all();

        return View::make('posts.index', compact('posts'));
    }

在Routes.php中:

Route::resource('posts', 'PostsController');

我使用Jeffrey Way的Generator来支持帖子实体。

同样在我的本地机器上工作正常。控制器不包含任何逻辑,它们只输出获取的数据。

错误日志为空。

任何想法要检查什么? .htaccess,也许? 这就是我在那里:

AddType application/x-httpd-php53 .php
<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

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

1 个答案:

答案 0 :(得分:9)

如评论中所述,如果没有来自应用程序记录器的相应日志文件条目,则500错误可能是.htaccess文件问题。

由于OP发现问题与重写有关(而不是使用php 5.3的指令):

由于这可能是Hostgator上的常见问题,因此您应该查看他们的帮助文档。

但是,我第一次尝试修复是添加RewriteBase指令:

RewriteBase /

所以它看起来像:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteBase /

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

请注意,这假设您从Web根目录而不是子目录运行Web应用程序。