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

247,732

Solution 1

Okay: This is what I did now and it's solved:

My httpd-vhosts.conf looks like this now:

<VirtualHost dropbox.local:80>
    DocumentRoot "E:/Documenten/Dropbox/Dropbox/dummy-htdocs"
    ServerName dropbox.local
    ErrorLog "logs/dropbox.local-error.log"
    CustomLog "logs/dropbox.local-access.log" combined
    <Directory "E:/Documenten/Dropbox/Dropbox/dummy-htdocs">
        # AllowOverride All      # Deprecated
        # Order Allow,Deny       # Deprecated
        # Allow from all         # Deprecated

        # --New way of doing it
        Require all granted    
    </Directory>
</VirtualHost>

First, I saw that it's necessary to have set the <Directory xx:xx> options. So I put the <Directory > [..] </Directory>-part INSIDE the <VirtualHost > [..] </VirtualHost>. After that, I added AllowOverride AuthConfig Indexes to the <Directory> options.

Now http://localhost also points to the dropbox-virtualhost. So I added dropbox.local to <VirtualHost *:80> which makes it as <VirtualHost dropbox.local:80>

FINALLY it works :D!

I'm a happy man! :) :)

I hope someone else can use this information.

Solution 2

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

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

Solution 3

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

Solution 4

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

Solution 5

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

Share:
247,732

Related videos on Youtube

Highmastdon
Author by

Highmastdon

C#.Net, Java, PHP, Nodejs, PostgreSQL, Oracle, SQL Server, MongoDB, Hadoop, HBase, Javascript, Typescript, git, bash, Fishshell, Jenkins, Rest, GraphQL, Web components, LitElement, React, Angular, Vue, ... Try new tech, keep the best of each

Updated on July 27, 2020

Comments

  • Highmastdon
    Highmastdon almost 4 years

    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>
    
  • Camilo Díaz Repka
    Camilo Díaz Repka over 11 years
    FWIW, I did the same and still had problems acceding my vhost. However, adding Require all granted after Allow from all made my configuration work.
  • Highmastdon
    Highmastdon over 11 years
    The httpd-vhosts.conf is a config file for Apache. Apache 'runs' the php-code. Download and install xampp and change the config as stated above.
  • funwhilelost
    funwhilelost over 10 years
    I also had to add 'Options FollowSymLinks' because my rewrite rules were not being allowed.
  • Pascalculator
    Pascalculator over 10 years
    As of Apache 2.4 the access control directives order, allow, deny and satisfy are deprecated. Make sure you are running a lower version when using these directives, or use Require in stead.
  • Sean Kendle
    Sean Kendle about 10 years
    Apache 2.4.3 - now working with above addition, plus I had the Apache and MySQL services "checked" in the Control Panel which was causing XAMPP CP to stop responding. Unchecked services - Apache ran, but Access Forbidden error. Added the above permissions, and it works now. Thanks!!
  • user2428118
    user2428118 about 10 years
    As @Pascalculator says, use Require all granted instead. I want to emphasize the instead because it wasn't working when I had the other options in my configuration, but when I only left this one behind it worked.
  • Ed Orsi
    Ed Orsi almost 10 years
    Basically this - I was missing the Options directive. Options Indexes FollowSymLinks was all I needed on Apache2.2, YMMV
  • Abhishek Goel
    Abhishek Goel almost 10 years
    This really helped. Thankyou so much. you saved my day. :)
  • Doidgey
    Doidgey over 9 years
    Can confirm all I needed to do was add the lines @CamiloDíazRepka suggested. I didn't need do anything else.
  • Doidgey
    Doidgey over 9 years
    Good man. All i needed was the Require all granted and all fixed for me.
  • JMac
    JMac about 9 years
    On my setup (xampp 3.2.1), having the "# << New way of doing it" at the end of the line was preventing Apache from starting correctly. After deleting that part of the line, everything worked fine!
  • Highmastdon
    Highmastdon about 9 years
    @JMac ough, that's a strange thing... Thanks for mentioning
  • Scrydan
    Scrydan about 9 years
    This worked wonderfully for me as opposed to the selected answer. For some reason "Require all granted" by itself as that answer suggests didn't work as it instantly crashed XAMPP. But this answer worked with those between <directory> so thanks for the answer.
  • ssi-anik
    ssi-anik almost 9 years
    .htaccess was not working till I changed to your answer, thanks.
  • Highmastdon
    Highmastdon over 8 years
    @davejal too bad you remove the personal side of stackoverflow, this means we have to act like robots and cannot express human feelings anymore, even on Stackoverflow? (I know this is insinuating: and indirectly lifting on the success of this post, maybe?)
  • davejal
    davejal over 8 years
    Sorry, didn't mean to remove it to hurt you, so I put it back, I personally think there should be more EQ expressed here also, but I've been brainwashed
  • Highmastdon
    Highmastdon over 8 years
    @davejal Thanks a lot and no problem :) I din't want to be a jerk about it. Indeed a little more EQ could be nice out here :)
  • Anoop saju
    Anoop saju almost 8 years
    Thanks so much.I was stuck with this problem
  • code-8
    code-8 over 7 years
    Can someone please help me out here ? I am trying to achieve the same thing in MAMP stackoverflow.com/q/40405663/4480164
  • code-8
    code-8 over 7 years
    Can someone please help me out here ? I am trying to achieve the same thing in MAMP stackoverflow.com/q/40405663/4480164
  • tatskie
    tatskie about 7 years
    when index.html is missing and you just want to show all pages on this folder, you may add only the following under <Directory> directive: Require all granted and Options Indexes FollowSymLinks
  • Theodore R. Smith
    Theodore R. Smith about 7 years
    ONLY Options All worked for me! It is the missing ingredient!
  • CPHPython
    CPHPython almost 5 years
    Setting different IP addresses for each virtual host worked! Unlike WAMP though, XAMP does not interpret each server name when they are all bundled up in one IP address (e.g. 127.0.0.1 localhost,test1.localhost).
  • Leandro Bardelli
    Leandro Bardelli almost 5 years
    @CPHPython thanks for mention the differences and improve my answer. Glad to help! I remember fought a lot with this issue
  • CPHPython
    CPHPython almost 5 years
    thank you, glad to help as well! Before finding your answer, I had spent quite a while trying to figure out why the windows' hosts were not reflecting the servernames.
  • Riccardo
    Riccardo over 2 years
    Thanks! Was going bananas!