Virtual Domain and subdomain in localhost [xampp]

CodeHolic

Adding a Virtual Host is a 2-step process:

1. Add a new entry to your computer’s hosts file.

File path :  /system32/driver/etc/host
127.0.0.1 localhost
::1 localhost

Add following line in host file

127.0.0.1 example.com
127.0.0.1 subdomain.example.com

2. Edit the Apache configuration file to accept Virtual Hosts and define the particular Virtual Hosts you want to setup on your computer.

File Path : /apache/conf/extra/httpd-vhosts.conf

Add Following code in httpd-vhosts.conf file

<VirtualHost *>

DocumentRoot "E:\xampp\htdocs\example"
ServerName example.com
<Directory "E:\xampp\htdocs\example">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Accept wildcard subdomains

Allow any subdomain for example.com

<VirtualHost *>
ServerName example.com
ServerAlias *.example.com
DocumentRoot "E:\xampp\htdocs\j9d"
</VirtualHost>

View original post

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