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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18293942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:17:53  来源:igfitidea点击:

Laravel 4 Internal Server Error 500 on Hostgator

.htaccesslaravellaravel-4internal-server-error

提问by Glad To Help

I have a Laravel 4 app deployed on shared Hostgator server.

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

When I navigate to:

当我导航到:

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

I can see the Laravel splash screen.

我可以看到 Laravel 启动画面。

but when I try to access any other route to, say, /users or /posts I am getting

但是当我尝试访问任何其他路由时,例如 /users 或 /posts 我得到

Internal Server Error 500

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

Controller:

控制器:

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

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

In Routes.php:

在 Routes.php 中:

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

I use Jeffrey Way's Generator to scaffold the posts entity.

我使用 Jeffrey Way 的 Generator 来搭建帖子实体的脚手架。

The same works fine on my local machine. Controllers don't contain any logic, they only output the fetched data.

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

Error logs are empty.

错误日志为空。

Any ideas what to check? .htaccess, maybe? Here is what I have there:

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

回答by fideloper

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

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

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

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

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

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

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

然而,我的第一个修复是添加一个RewriteBase指令:

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.

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