昨天我在Windows 8机器上安装了Apache 2.2,PHP 5.3和MySQL。我在两者上使用相同的vhost / .htaccess文件,但它可以在我的Mac而不是Windows上运行。基本上当我去“mysite.dev”它呈现网站的主页,但一旦我去任何页面,如“mysite.dev/about/”我得到403禁止错误。
我已经验证Apache在我的计算机上作为“系统”运行,然后确保从站点文件夹到root的所有权限都设置为用户/组系统的完全访问权限。
我已经尝试了很多东西,并且无法解决这个问题,而且它很烦人。无论如何,我已经在所有设置/日志下面发布了。谢谢你提前。
虚拟主机:
<VirtualHost *:80>
ServerAdmin MyEmail@gmail.com
DocumentRoot "C:/Users/Michael/Dropbox/Sites/onmytv"
ServerName onmytv.dev
ServerAlias www.onmytv.dev
<Directory "C:/Users/Michael/Dropbox/Sites/onmytv">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Deny,Allow
Allow from all
</Directory>
</VirtualHost>
htaccess的:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php/$1 [L]
网页上显示错误:
Forbidden
You don't have permission to access /C:/Users/Michael/Dropbox/Sites/onmytv/index.php/about/ on this server.
error.log中
[error] [client 127.0.0.1] (20023)The given path was above the root path: Cannot map GET /about/ HTTP/1.1 to file
的access.log
127.0.0.1 - - [02/Nov/2012:17:57:17 -0400] "GET /about/ HTTP/1.1" 403 256
答案 0 :(得分:3)
解决方案是更改.htaccess文件中的以下内容
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php/$1 [L]
到
RewriteRule ^(.*)$ index.php/$1 [L]
感谢@Svetlio提供的有用评论:)
答案 1 :(得分:2)
使用此:
<VirtualHost *:80>
ServerAdmin MyEmail@gmail.com
DocumentRoot "C:/Users/Michael/Dropbox/Sites/onmytv"
ServerName onmytv.dev
ServerAlias www.onmytv.dev
<Directory "C:/Users/Michael/Dropbox/Sites/onmytv">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>