WAMP or XAMPP server lets our sites to browse by using the url: http://localhost. For eg: http://localhost/mysite.
But we may need to test out environments which would require different domains, like http://local.server.com.
For this, we need to configure the virtual hosts file of our apache server.
These are the steps we need to configure vitual host on windows os:
1. Open vhosts.conf file. Location: xampp/apache/conf/extra
2. Add the following code at the end of the file.
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost local.server.com:80> <!-- this is the vitual host -->
DocumentRoot "D:\xampp\htdocs"
ServerName local.server.com
<Directory "D:\xampp\htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3. Edit the windows hosts file residing at C:/Windows/System32/drivers/etc/hosts. Add the following code at the end of the file.
127.0.0.1 local.server.com
4. Save and restart apache server.
5. Now we can browse our site using the url: http://local.server.com/sitename
Comments
Post a Comment