2013-08-17 103 views
0

我在共享HostGator服务器上部署了Laravel 4应用程序。Laravel 4 HostGator上的内部服务器错误500

当我浏览到:

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

我可以看到Laravel闪屏。

但是当我尝试访问任何其他途径,比如,/用户/或帖子我越来越

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> 
+0

没有服务器日志的500错误肯定是.htaccess。它也可能会丢失诸如PDO或mcrypt之类的php扩展(通常只有隐藏才会出现这种情况)如果php抑制错误 - 我不认为Laravel会这样做)。尝试将index.php文件添加到URL中,然后删除您的htaccess文件以测试htaccess文件是否是问题。 – fideloper

+0

你是对的@fideloper,删除一切从的.htaccess除非该指令使用PHP 5.3,使应用程序的工作: 将AddType应用/的X的httpd-php53 .PHP 当然,现在的URL必须包括的index.php 在我的情况:mydomain.com/laravel/public/index.php/posts 所以,现在我知道.htaccess导致的问题,任何人都可以提出修复它? –

+0

我在这里找到了解决方案:http://stackoverflow.com/a/16116678/385402 –

回答

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根目录而不是子目录。

+0

如果它在一个子目录中,如:public_html/domain.com/laravel?如果你已经使用过它,那么如果你知道RewriteBase指令应该放在你的头脑之上,那么它将会非常有用。 –

+1

'RewriteBase/laravel' - 基本上,无论子文件夹是什么。如果您通过“example.com/laravel”和“RewriteBase/laravel”访问网站。如果您通过“example.com/some/folders/laravel”然后“RewriteBase/some/folders/laravel”访问它。 – fideloper

+0

这对我来说很有效,因为我没有在我的'vhost'文件中授权'AllowOverride All'。这阻止了'htaccess'文件中的重写。 – h4k1m