0

我在共享 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 的生成器来搭建帖子实体。

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

错误日志为空。

任何想法要检查什么?.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>
4

1 回答 1

9

As mentioned in comments, a 500 error without a corresponding log file entry from the application logger is likely an .htaccess file issue.

Since the OP found the issue is related to the rewrite (and not the directive to use php 5.3):

Since this is probably a common issue on Hostgator, you should check with their help docs.

However, my first stab at a fix would be to add a RewriteBase directive:

RewriteBase /

So it would look like:

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

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

Note that this assumes you're running the web application form the web root and not a sub-directory.

于 2013-08-18T16:12:44.013 回答