Error 403 with Virtual Host [SOLVED]

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

Error 403 with Virtual Host [SOLVED]

Postby Jubilee » 05. March 2013 01:33

Hello,

I'm trying to set up a virtual host on my machine but when I go to localhost I get Error 403.

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.


It seems to be a problem with the httpd-vhosts.conf file - when I comment out my code I can see my existing projects (not on virtual host) but if I uncomment my code I get the Error 403 message.

I will try to explain my set-up.
Xampp is installed in: C:\Program Files\Programs\xampp
httpd-vhosts.conf: C:\Program Files\Programs\xampp\apache\conf\extra
httpd.conf: C:\Program Files\Programs\xampp\apache\conf
hosts: C:\Windows\System32\Drivers\etc

hosts
Code: Select all
#I REMOVED COMMENTED CODE FOR READABILITY
#THE LINE BELOW IS ALL THAT IS DIFFERENT FROM THE DEFAULT FILE
127.0.0.1       zend.localhost


httpd.vhosts.conf
Same as default except I added the following at the end
Code: Select all
<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
DocumentRoot "C:/Users/Jubilee/Documents/NetBeansProjects/proj01/public"
ServerName zend.localhost
##ServerAlias www.IncubatorDoctrineZF.localhost
##ErrorLog "logs/IncubatorDoctrineZF.localhost-error.log"
#CustomLog "logs/IncubatorDoctrineZF.localhost-access.log" combined
<Directory "C:/Users/Jubilee/Documents/NetBeansProjects/proj01/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>


Now when I enter either zend.localhost or localhost in my browser I get the Error 403 message

I'm out of my depth here - any help would be appreciated.

Jubilee
Last edited by Jubilee on 06. March 2013 02:30, edited 1 time in total.
Jubilee
 
Posts: 2
Joined: 05. March 2013 01:08
Operating System: Windows 8

Re: Error 403 with Virtual Host

Postby JonB » 05. March 2013 03:42

A. XAMPP should not be installed within the Program Files hierarchy. There are multiple reasons - you just ran into #2

1. Generally programs that are ported from Linux should not be installed in paths that contain spaces or special characters (unpredictable results).

2. The Program Files hierarchy is a protected Windows OS area. (your data files are residing in an area that is reserved for Programs that are registered with Windows)

With regard #2 - You 'might' be able to operate that way if you launched the Control Panel as Administrator, but you would still be open to problem #1

Generally, we recommended you install XAMPP in the root of a drive - such as c:\xampp.

B. Putting your datafiles in the Users hierachy - also poor idea. Another restricted hierarchy (again running as Administrator may or may not fix).

Remember Apache, Perl, PHP and MySQL did not grow up in Bill Gates Garden. The way XAMPP works and is installed - Windows does not know it exists - it is registry-agnostic. IF you look at the 'details' - all you will find are executables, configuration files, and Command Line calls + hackattacks fine Control Panel over the top - not a registry entry in sight. Net summary of advice -- put XAMPP + any other folder you want to work with it (XAMPP) outside the "Windows OS reserved" areas.

Good Luck

:)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Error 403 with Virtual Host

Postby Altrea » 05. March 2013 07:16

Hi Jubilee,

The main reason for your issue is the new Apache access rule syntax introduced with Apache 2.4.
More to read here: viewtopic.php?f=16&t=50985

But i totally agree with all of JonB's reasons. This are some best practices for XAMPP installation which can avoid very common problems.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Error 403 with Virtual Host

Postby Jubilee » 06. March 2013 02:24

Thank you both for your input.

I agree with your point about spaces but I installed before reading any documentation.

Altrea you were correct - I edited my httpd-vhosts.conf file, I commented out the lines

Order allow,deny
Allow from all


and replaced them with

Require all granted


The virtual host now reads

<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
DocumentRoot "C:/Users/Jubilee/Documents/NetBeansProjects/proj01/public"
ServerName zend.localhost
##ServerAlias www.IncubatorDoctrineZF.localhost
##ErrorLog "logs/IncubatorDoctrineZF.localhost-error.log"
#CustomLog "logs/IncubatorDoctrineZF.localhost-access.log" combined
<Directory "C:/Users/Jubilee/Documents/NetBeansProjects/proj01/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
##Order allow,deny
##Allow from all
</Directory>
</VirtualHost>


Thank you both very much.

J.
Jubilee
 
Posts: 2
Joined: 05. March 2013 01:08
Operating System: Windows 8


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 124 guests