Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Hostgator上的Laravel 4内部服务器错误500_.htaccess_Laravel_Laravel 4_Internal Server Error - Fatal编程技术网

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

.htaccess Hostgator上的Laravel 4内部服务器错误500,.htaccess,laravel,laravel-4,internal-server-error,.htaccess,Laravel,Laravel 4,Internal Server Error,我在共享Hostgator服务器上部署了一个Laravel 4应用程序 当我导航到: http://mydomain.com/laravel/public/ 我可以看到拉威尔的闪屏 但是当我尝试访问任何其他路径时,比如说,/用户或/帖子 Internal Server Error 500 http://mydomain.com/laravel/public/posts 控制器: public function index() { $posts = $this->

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

当我导航到:

http://mydomain.com/laravel/public/
我可以看到拉威尔的闪屏

但是当我尝试访问任何其他路径时,比如说,/用户或/帖子

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的生成器构建posts实体

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

错误日志为空

你知道要查什么吗。也许吧? 以下是我的资料:

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>
AddType应用程序/x-httpd-php53.php
选项-多视图
重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

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

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

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

但是,我的第一个尝试是添加一个指令:

RewriteBase /
所以它看起来像:

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

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

选项-多视图
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

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

500没有服务器日志的错误肯定是.htaccess。它也可能缺少诸如PDO或mcrypt之类的php扩展(不太可能,因为通常只有在php抑制错误时才会隐藏——我认为Laravel不会这样做)。尝试将index.php文件添加到URL中,并删除htaccess文件以测试htaccess文件是否存在问题。你是对的@fideloper,删除.htaccess中的所有内容,除了使用PHP5.3的指令,都会使应用程序工作:AddType application/x-httpd-php53.php当然,在我的例子中,URL现在必须包含index.php:mydomain.com/laravel/public/index.php/posts,所以现在我知道.htaccess是问题的根源,有人能为它提出解决方案吗?我在这里找到了解决方案:如果它位于public_html/domain.com/laravel这样的子目录中呢?如果您以前使用过这个命令,那么如果您知道RewriteBase指令应该在您的脑海中出现,这将非常有帮助。
RewriteBase/laravel
-基本上,不管子文件夹是什么。如果您通过“example.com/laravel”访问该网站,则
RewriteBase/laravel
。如果您通过“example.com/some/folders/laravel”访问它,那么
RewriteBase/some/folders/laravel
。这对我来说很有效,因为我没有授权
AllowOverride我的
vhost
文件中的所有内容。这阻止了
htaccess
文件内部的重写。我找到了答案:。感谢所有人在Rackspace Cloudsites上有相同的问题,并且
RewriteBase/
修复了它。