0
  • Windows 7 Ultimate (64-bit)
  • Apache HTTP Server 2.2.15 (32-bit)
  • PHP 5.3.2 (32-bit)

httpd.conf is default except I uncommented the line for mod_rewrite and the one that loads httpd-vhosts.conf, which looks like this:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

<Directory "D:/Path/To/Sites">
  Options Indexes
  Order Deny,Allow
  Allow from all
</Directory>

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/Path/To/Site 1"
    ServerName site1.local
    ServerAlias www.site1.local
    ErrorLog "logs/site1.local-error.log"
    LogLevel debug
    CustomLog "logs/site1.local-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/Path/To/Sites/Site 2"
    ServerName site2.local
    ServerAlias www.site2.local
    ErrorLog "logs/site2.local-error.log"
    LogLevel debug
    CustomLog "logs/site2.local-access.log" common
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "D:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs"
   ServerName localhost
</VirtualHost>

Windows hosts file forwards site1.local and site2.local to 127.0.0.1.

When trying to access site2.local, .htaccess is clearly being ignored. In site2.local-error.log, the ONLY error each time I try to access it is this:

[Wed Jul 21 17:57:06 2010] [error] [client 127.0.0.1] client denied by server configuration: D:/Path/To/Sites/Site 2/.htaccess

But, even when I delete everything in .htaccess, I still get the same error. Moving Directory inside VirtualHost makes no difference; nor does moving the contents of Site 2 to htdocs.

3 Answers 3

0

Apparently the .htaccess wasn't being read because I didn't allow configuration overrides; if I added "AllowOverride All" to my Virtual Hosts Directory, it worked—except for mod_rewrite, due to the following error:

Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden

After I added in Options FollowSymLinks everything worked.

Final code:

<Directory "D:/Path/To/Sites">
  Options Indexes FollowSymLinks
  AllowOverride All
  Order Deny,Allow
  Allow from all
</Directory>
0

I ran into this problem working locally with Apache & Windows, but it wasn't an AllowOverride thing. I finally solved it in a very brute-force way that you should never use on a live server but worked for me because it's just a local environment:

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

I don't understand why the logic to prevent Apache from serving out .htaccess files was blocking them from being consumed in a VirtualHost. I'm sure I have it set wrong, but the quick fix for me was to just remove that whole block.

0

Note that I just run in this problem. The Order + Deny | Allow was definitively the culprit.

The fact is that the application I just installed has a .htaccess file in each directory and the directory I was trying to see had to be the exact directory accessed for the connection to be accepted.

To find the problem, I looked at the .htaccess file of each directory... By adding the index.php at the end of the URI helped, although the truth was that I did not put an ending / and the parent directory was forbidding access to the directory file.

So the following would fail because .htaccess in the install directory forbids access to everything:

http://exmaple.com/admin/install

And the following would work just fine:

http://exmaple.com/admin/install/
http://exmaple.com/admin/install/index.php

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .