在没有 .htaccess 的情况下使用 .htaccess 403(禁止错误)安装 ZF2 500 错误

Installing ZF2 500 error with .htaccess 403 (Forbidden error) without .htaccess

我一直在尝试设置 ZF2,我在 /home/jack/instantpk/framework/ 中设置了目录,"public" 目录包含 .htaccess 和该文件夹中的 index.php /home/jack/instantpk/framework/public/index.php | .htaccess

我已经配置了我的主机,以便: 127.0.0.1 zf2.localhost.com 已设置。

我还修改了 /etc/apache2/sites-available 目录中的 000-default.conf 文件,现在它显示为

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName zf2.localhost.com
        ServerAlias zf2.localhost.com
        DocumentRoot /home/jack/instantpk/framework/public

   <Directory /home/jack/instantpk/framework/public>
       AllowOverride All
       Order allow,Deny
       Allow from all
   </Directory>
</VirtualHost>

这是我的 .htaccess 文件,位于 home/jack/instantpk/framework/public/

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}:: ^(/.+)(.+)::$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

如果我删除 .htaccess 文件,我会收到 403 Forbidden 错误: You don't have permission to access /**** on this server.

如果该文件存在,我会收到 500 错误:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

当我尝试访问 http://zf2.localhost.com/

时出现这两个错误

我已经研究了一段时间了,在线阅读似乎没有任何用处 - 如果有人能指出正确的方向,我将不胜感激!

我的问题是 mod 重写未启用,我最近更新了我的 apache 版本,因此 .htaccess 引发了 500 错误。

至于 403 错误 - 我不确定,我通过将我的目录移动到 /var/www 文件夹

来解决这个问题

我犯了一些愚蠢的错误,希望这对以后的其他人有所帮助!