[apache] Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7)

I've got a XAMPP installation running on Windows 7.

As soon as I add a VirtualHost to httpd-vhosts.conf, BOTH the 'regular' http://localhost AND the new dropbox.local aren't working.

This is what I added to my httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ServerAlias www.dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
</VirtualHost>

So I looked up my dropbox.local-error.log for any information:

[Thu Feb 02 10:41:57 2012] [error] [client 127.0.0.1] client denied by server configuration: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

This error seems to be solved by adding

<directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
     Allow from all
</directory>

But now I get this error in dropbox.local-error.log:

[Thu Feb 02 10:45:56 2012] [error] [client ::1] Directory index forbidden by Options directive: E:/Documenten/Dropbox/Dropbox/dummy-htdocs/

Furthermore when I try to access http://localhost, I dont get any error in the regular error.log, although I get the error 403 when I try to access it.

Can anybody help... It's driving me mad :S

EDIT: Also in httpd.conf there is the following (I've seen it mentioned multiple times, so before anyone says it):

<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

This question is related to apache windows-7 xampp virtualhost vhosts

The answer is


For me worked when I changed "directory" content into this:

<Directory  "*YourLocation*">
Options All
AllowOverride All
Require all granted  
</Directory>

I'm using XAMPP 1.6.7 on Windows 7. This article worked for me.

I added the following lines in the file httpd-vhosts.conf at C:/xampp/apache/conf/extra.
I had also uncommented the line # NameVirtualHost *:80

<VirtualHost mysite.dev:80>
    DocumentRoot "C:/xampp/htdocs/mysite"
    ServerName mysite.dev
    ServerAlias mysite.dev
    <Directory "C:/xampp/htdocs/mysite">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

After restarting the apache, it were still not working. Then I had to follow the step 9 mentioned in the article by editing the file C:/Windows/System32/drivers/etc/hosts.

# localhost name resolution is handled within DNS itself.
     127.0.0.1       localhost
     ::1             localhost
     127.0.0.1       mysite.dev  

Then I got working http://mysite.dev


After so many changes and tries and answers. For

SOs: Windows 7 / Windows 10

Xampp Version: Xampp or Xampp portable 7.1.18 / 7.3.7 (control panel v3.2.4)

Installers: win32-7.1.18-0-VC14-installer / xampp-windows-x64-7.3.7-0-VC15-installer

  1. Do not edit other files like httpd-xampp

  2. Stop Apache

  3. Open httpd-vhosts.conf located in **your_xampp_directory**\apache\conf\extra\ (your XAMPP directory might be by default: C:/xampp/htdocs)

  4. Remove hash before the following line (aprox. line 20): NameVirtualHost *:80 (this might be optional)

  5. Add the following virtual hosts at the end of the file, considering your directories paths:

    ##127.0.0.1
    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs"
        ServerName localhost
        ErrorLog "logs/localhost-error.log"
        CustomLog "logs/localhost-access.log" common
    </VirtualHost>
    
    ##127.0.0.2
    <VirtualHost *:80>
        DocumentRoot "F:/myapp/htdocs/"
        ServerName test1.localhost
        ServerAlias www.test1.localhost
        ErrorLog "logs/myapp-error.log"
        CustomLog "logs/myapp-access.log" common
        <Directory  "F:/myapp/htdocs/">
            #Options All # Deprecated
            #AllowOverride All # Deprecated
            Require all granted  
        </Directory>
    </VirtualHost>
    
  6. Edit (with admin access) your host file (located at Windows\System32\drivers\etc, but with the following tip, only one loopback ip for every domain:

    127.0.0.1 localhost
    127.0.0.2 test1.localhost
    127.0.0.2 www.test1.localhost
    

For every instance, repeat the second block, the first one is the main block only for "default" purposes.


Thank you, that worked! But I replaced this

AllowOverride AuthConfig Indexes

with that

AllowOverride All

Otherwise, the .htaccess didn't work: I got problems with the RewriteEngine and the error message "RewriteEngine not allowed here".


Above suggestions didn't worked for me. I got it running on my windows, using inspiration from http://butlerccwebdev.net/support/testingserver/vhosts-setup-win.html

For Http inside httpd-vhosts.conf

<Directory "D:/Projects">       
AllowOverride All
Require all granted
</Directory>

##Letzgrow
<VirtualHost *:80>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev    
</VirtualHost>

For using Https (Open SSL) inside httpd-ssl.conf

<Directory "D:/Projects">       
AllowOverride All
Require all granted
</Directory>

##Letzgrow
<VirtualHost *:443>
DocumentRoot "D:/Projects/letzgrow"
ServerName letz.dev
ServerAlias letz.dev    
</VirtualHost>

Hope it helps someone !!


For me (also XAMPP on Windows 7), this is what worked:

<Directory "C:\projects\myfolder\htdocs">`
   AllowOverride All
   Require all granted
   Options Indexes FollowSymLinks
</Directory>` 

It is this line that would cause the 403:

Order allow,deny

For many it's a permission issue, but for me it turns out the error was brought about by a mistake in the form I was trying to submit. To be specific i had accidentally put a "greater than" sign after the value of "action". So I would suggest you take a second look at your code.


I am using xampp 1.7.3. Using inspiration from here: xampp 1.7.3 upgrade broken virtual hosts access forbidden

INSTEAD OF add <Directory> .. </Directory> in httpd-vhosts.conf, I add it in httpd.conf right after <Directory "D:/xampplite/cgi-bin"> .. </Directory>.

Here is what I add in httpd.conf:

<Directory "D:/CofeeShop">
    AllowOverride All
    Options  All
    Order allow,deny
    Allow from all
</Directory>

And here is what I add in httpd-vhosts.conf

<VirtualHost *:8001>
    ServerAdmin [email protected]
    DocumentRoot "D:/CofeeShop"
    ServerName localhost:8001
</VirtualHost>

I also add Listen 8001 in httpd.conf to complete my setting.

Hope it helps


Examples related to apache

Enable PHP Apache2 Switch php versions on commandline ubuntu 16.04 Laravel: PDOException: could not find driver How to deploy a React App on Apache web server Apache POI error loading XSSFWorkbook class How to enable directory listing in apache web server Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details How to enable php7 module in apache? java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing while starting Apache server on my computer

Examples related to windows-7

ng is not recognized as an internal or external command Why am I getting ImportError: No module named pip ' right after installing pip? How to Delete node_modules - Deep Nested Folder in Windows Telnet is not recognized as internal or external command Multiple -and -or in PowerShell Where-Object statement How do I set ANDROID_SDK_HOME environment variable? Run Batch File On Start-up Why isn't .ico file defined when setting window's icon? How to access shared folder without giving username and password Can't start hostednetwork

Examples related to xampp

Xampp localhost/dashboard phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO) Is there way to use two PHP versions in XAMPP? Where to find htdocs in XAMPP Mac phpMyAdmin access denied for user 'root'@'localhost' (using password: NO) How to downgrade php from 7.1.1 to 5.6 in xampp 7.1.1? How to turn on/off MySQL strict mode in localhost (xampp)? mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it How to install mcrypt extension in xampp Fatal error: Uncaught Error: Call to undefined function mysql_connect()

Examples related to virtualhost

how to create virtual host on XAMPP Site does not exist error for a2ensite nginx missing sites-available directory Apache VirtualHost and localhost Apache error: _default_ virtualhost overlap on port 443 Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7) client denied by server configuration Apache VirtualHost 403 Forbidden How to debug an apache virtual host configuration? Apache default VirtualHost

Examples related to vhosts

Apache giving 403 forbidden errors Adding VirtualHost fails: Access Forbidden Error 403 (XAMPP) (Windows 7) How to redirect to a different domain using NGINX?