How to create virtual host on XAMPP to remove “public” path

Step 1: Add new domain name to Windows host file

Open c:\windows\system32\drivers\etc\hosts. edit hosts file and add a line

127.0.0.1 localhost firstapp.local

Untitled

Step 2: We will add a Virtual Host setting so that we can point the URL http://firstapp.local. open [XAMPP_Home]\apache\conf\extra\httpd-vhosts file and edit it.

<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
DocumentRoot “C:/xampp/htdocs/firstapp/public”
ServerName localhost
##ServerAlias firstapp.local
ErrorLog “C:/xampp/htdocs/firstapp/error.log”
CustomLog “C:/xampp/htdocs/firstapp/custom-error.log” common
</VirtualHost>

Step 3: Restart Apache. You may get XAMPP new security concept. The httpd-xampp.conf has been configured to be very restrictive in terms of path/folder access.

web-access-forbidden

 

Step 4: You can turn-off the restriction. Open [XAMP_Home]/apache/conf/httpd-xampp.conf and look for the followings:

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the “default” to be a very restrictive set of
# features.
#
<Directory />
AllowOverride none
Require all denied
</Directory>

Change the highlighted codes above into:

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the “default” to be a very restrictive set of
# features.
#
<Directory />

# “default” restriction is turned off
AllowOverride All
        Order Allow,Deny
        Allow from all

</Directory>

Restart Apache. Go to http://firstapp.local

Thats it.

 

For more information (Multiple Virtual Hosts)

How To Setup Virtual Hosts Using XAMPP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s