我一直在尝试设置ZF2,我在/home/jack/instantpk/framework/
设置了目录,其中包含" public"包含.htaccess和该文件夹中index.php的目录/home/jack/instantpk/framework/public/index.php | .htaccess
我配置了我的主机,以便:
127.0.0.1 zf2.localhost.com
已经确定了。
我还修改了000-default.conf
目录中的/etc/apache2/sites-available
文件,现在它已读取
<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}::$1 ^(/.+)(.+)::\2$
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/
我现在已经摆弄了一段时间,在网上阅读似乎没什么用 - 如果有人能指出我正确的方向,我会很感激!
答案 0 :(得分:0)
我的问题是没有启用mod重写,我最近更新了我的apache版本,因此.htaccess引发了500错误。
至于403错误 - 我不确定,我通过将目录移动到/ var / www文件夹来解决这个问题
我的相当愚蠢的错误,希望将来帮助其他人!