简体   繁体   English

Slim框架-500内部服务器错误

[英]Slim framework - 500 Internal Server Error

There is probably a very simple solution to this but I can't seem to figure it out. 对此可能有一个非常简单的解决方案,但我似乎无法弄清楚。 I'm working a Slim Project which was working fine. 我正在做一个Slim Project,效果很好。 I just did a fresh install of Yosemite on my system. 我刚刚在系统上重新安装了优胜美地。 I have installed MySQL and enabled PHP (5.5.20). 我已经安装了MySQL并启用了PHP(5.5.20)。 I moved my Slim project under localhost/~username/apiproject . 我将Slim项目移到localhost/~username/apiproject

I get a '500 Internal Server Error' when I try to access my project. 尝试访问我的项目时出现“ 500 Internal Server Error”。 I have tried putting a simple html file in the same folder and accessing it via the browser and still get the same error on the HTML file. 我尝试将一个简单的html文件放在同一文件夹中,并通过浏览器访问它,但在HTML文件上仍然遇到相同的错误。 This tells me that the browser isn't able to access this folder. 这表明浏览器无法访问该文件夹。

Next I tried removing the .htaccess file from the root of the project. 接下来,我尝试从项目的根目录中删除.htaccess文件。 When I did that, I was able to access the HTML page which I placed in the folder. 完成此操作后,便可以访问放置在文件夹中的HTML页面。 However, I am not able to access the project. 但是,我无法访问该项目。

I'm assuming this has to be related to my Apache setting or my .htaccess file. 我假设这与我的Apache设置或.htaccess文件有关。 I have also enabled mod_rewrite in my Apache settings. 我还在我的Apache设置中启用了mod_rewrite Here is what is in my .htaccess file: 这是我的.htaccess文件中的内容:

RewriteEngine On
RewriteBase localhost/~username/apiproject
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

我在PHP 5.5.12中遇到了相同的问题,解决方案是取消注释httpd.conf中的以下行:

LoadModule rewrite_module modules/mod_rewrite.so

It is really a simple solution. 这确实是一个简单的解决方案。 RewriteBase must begin with a slash (/). RewriteBase必须以斜杠(/)开头。
It must be the part of the url after the document root. 它必须是文档根目录之后url的一部分。 In this case, I suppose it should be 在这种情况下,我想应该是

RewriteBase /apiproject/

If your document root is /localhost, then RewriteBase must be /~username/apiproject/, but the first slash can not be absent. 如果您的文档根目录是/ localhost,则RewriteBase必须是/〜username / apiproject /,但是不能缺少第一个斜杠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM