htacces files workign on localhost, but not on vhosts...

Problems with the Windows version of XAMPP, questions, comments, and anything related.

htacces files workign on localhost, but not on vhosts...

Postby evank » 24. January 2008 05:20

On a Windows XP machine, I've created two name-based vhosts (in conf/extra/httpd-vhosts.conf), and put .htaccess files in the document roots of both requiring basic authentication. The strange thing is, the htaccess files work in the default vhost, but not in the second one I've created. Following is the contents of the httpd-vhosts.conf file:

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

# Default virtual host, same as localhost
<VirtualHost _default_:80>
    ServerName localhost
</VirtualHost>

# Custom vhost (where the htaccess files are not working
<VirtualHost *:80>
    DocumentRoot "D:/source/example.com/htdocs"
    ServerName example.com
    <Directory "D:/source/example.com/htdocs">
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog logs/example.com-error.log
    CustomLog logs/example.com-access.log common
</VirtualHost>


Everything else for the vhost works correctly (after a quick edit to my hosts file for dns resolution). Am I missing something painfully obvious?
evank
 
Posts: 1
Joined: 24. January 2008 04:56

Postby Izzy » 24. January 2008 05:46

Your localhost configurations (unless changed in the vhosts file) are contained in the httpd.conf file, which you can check out for reference, and is why the .htaccess file can be accessed on localhost.

Add this to the <Directory> directive just below the Options list, which you have omitted, but would perhaps need to be added at some later stage:
AllowOverride All

<VirtualHost *:80>
DocumentRoot "D:/source/example.com/htdocs"
ServerName example.com
<Directory "D:/source/example.com/htdocs">
Options Indexes +FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog logs/example_com_error.log
CustomLog logs/example_com_access.log common
</VirtualHost>

Adding AllowOverride All will permit .htaccess files to be parsed by the server on a directory by directory basis.
http://httpd.apache.org/docs/2.2/howto/htaccess.html
http://httpd.apache.org/docs/2.3/mod/co ... owoverride

Also note the error and access log entries have been edited as the dot may give issues.

This is incorrect
<VirtualHost _default_:80>

and should be:
<VirtualHost *:80>
which must match the NameVirtualHost *:80 entry.

We are using an IP wild card * here.

A reference quote from this link:
http://httpd.apache.org/docs/2.3/mod/co ... irtualhost
Argument to <VirtualHost> directive

Note that the argument to the <VirtualHost> directive must exactly match the argument to the NameVirtualHost directive.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 128 guests