Programming » Other

Virtual Host in XAMPP

1. Go to C:\Windows\system32\drivers\etc folder and add this line to the hosts file

127.0.0.1 thesite.lcom

Virtual host Apache, hosts file

2. Go to  C:\xampp\apache\conf\extra\ and add this to the file httpd-vhosts.conf

NameVirtualHost *

<VirtualHost *>
  DocumentRoot "C:\xampp\htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost *>
  DocumentRoot "C:\Documents\sites\shop"
  ServerName thesite.lcom
  
  <Directory "C:\Documents\sites\shop">
    Require all granted
  </Directory>
</VirtualHost>
DocumentRoot - path to the local site folder
ServerName - the local server custom name (from the hosts file)
Require all granted - grant access to the site through the local server

Virtual host Apache, conf folder

3. Restart the Apache server

Virtual host Apache, server restart

4. Type the URL in a browser

thesite.lcom

Virtual host Apache, type URL

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>