Apache 403 (Forbidden) on subdirectory on Windows

一世执手 提交于 2021-02-11 12:09:52

问题


So yesterday i installed Apache 2.2, PHP 5.3, and MySQL on my Windows 8 Machine. I am using the same vhost / .htaccess files on both but it works on my Mac and not Windows. Basically When i go to "mysite.dev" it renders the homepage of the site, but once i go to any page, such as "mysite.dev/about/" i get a 403 Forbidden Error.

I have verified that Apache runs as "System" on my computer and then made sure all permissions from the site folder to root are set to Full Access for the user/group System.

I've tried many many things and cant figure this out and its rather annoying. Anyways i've posted below all of the settings / logs. Thanks in advanced.

vhosts:

<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]

Error displayed on webpage:

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

回答1:


The solution was to change the following the in .htaccess file

RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php/$1 [L]

to

RewriteRule ^(.*)$ index.php/$1 [L]

Thanks @Svetlio for that useful comment :)




回答2:


Use this:

<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>


来源:https://stackoverflow.com/questions/13203608/apache-403-forbidden-on-subdirectory-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!