【发布时间】:2013-08-17 22:38:10
【问题描述】:
我在共享 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>
【问题讨论】:
-
500 没有服务器日志的错误肯定是 .htaccess。它也可能缺少诸如 PDO 或 mcrypt 之类的 php 扩展(这不太可能,因为通常只隐藏如果 php 抑制错误 - 我不认为 Laravel 会这样做)。尝试将 index.php 文件添加到 URL,并删除您的 htaccess 文件以测试 htaccess 文件是否是问题。
-
你是对的@fideloper,从 .htaccess 中删除所有内容,除了使用 PHP 5.3 的指令使应用程序工作:AddType application/x-httpd-php53 .php 当然,现在的 URL 必须包含索引.php 在我的情况下:mydomain.com/laravel/public/index.php/posts 现在我知道 .htaccess 导致了这个问题,任何人都可以建议修复它吗?
-
我在这里找到了解决方案:stackoverflow.com/a/16116678/385402
标签: .htaccess laravel laravel-4 internal-server-error