Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAMPP Windows Apache VirtualHost 403 Forbidden

I had XAMPP running fine with virtual hosts on my winodws 8 machine until I was forced to restart my computer (windows update). After restarting I've noticed my virtual hosts weren't working any more. Instead of trouble shooting too much I decided to reinstall XAMPP (currently have XAMPP 3.1.0 running. Which is runnign Apache v 2.4.3)

I have my windows host file edited to redirect sitename.localhost to 127.0.0.1 and this is what I have in my httpd-vhost.conf:

 NameVirtualHost *
      <VirtualHost *>
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
      </VirtualHost>
      <VirtualHost *>
        DocumentRoot "C:\Users\USER\Documents\sitename"
        ServerName sitename.localhost
      <Directory "C:\Users\USER\Documents\sitename">
        Order deny,allow
        Allow from all
      </Directory>
    </VirtualHost>

Every time I try to access http://sitename.localhost I get a 403 Access Forbidden error. Any idea what I'm doing wrong?

like image 483
Zaki Aziz Avatar asked Dec 26 '22 11:12

Zaki Aziz


2 Answers

Try adding Require all granted to the Directory configuration:

NameVirtualHost *

<VirtualHost *>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *>
    DocumentRoot "C:\Users\USER\Documents\sitename"
    ServerName sitename.localhost
    <Directory "C:\Users\USER\Documents\sitename">
        Order deny,allow
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

Also, try to set reading permissions to the web site folder for Authenticated users.

like image 196
Guillermo Gutiérrez Avatar answered Jan 12 '23 22:01

Guillermo Gutiérrez


This will list out as index.

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:\Users\USER\Documents\sitename"
    ServerName projectname.dev
    ServerAlias projectname.dev
    <Directory "C:\Users\USER\Documents\sitename">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
like image 39
Ramesh Avatar answered Jan 12 '23 22:01

Ramesh