Create Subdomain in localhost using Apache Xampp
Subdomain in localhost using Apache Xampp
Today, we’re sharing how to create subdomain in localhost using Apache Xampp. Following our tutorial, you can Create multiple Subdomain in localhost using Apache Xampp.
Requirement:
- Xampp Pre-installed (Latest Version)
- Administrator privileges
- Notepad++ (Optional)
Method:
- First of all stop Apache, if running through XAMPP Control Panel.
- Now navigate to following directory
C:\xampp\apache\conf\extra
- Now open httpd-vhosts.conf file using Notepad++ Editor. Please copy the file as backup before editing the core file
- Add the following lines in the end of the your file. Change example to your subdomain
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/example" ServerName example.localhost.com </VirtualHost>
- Now save the file or Press Ctrl+S
- Now open Notepad or Notepad++ as an Administrator
- open the following file
C:\Windows\System32\drivers\etc\hosts
- Add the following code to your hosts file
127.0.0.1 example.localhost.com
- Change example to your subdomain. Now save the file.
- Start the Apache Server using Xampp Control Panel
- Navigate to your subdomain like example.localhost.com
- Your subdomain is ready
- To create another Subdomain in localhost using Apache Xampp, just Add the following code to httpd-vhosts.conf
<VirtualHost *:80> DocumentRoot "C:/xampp/htdocs/example1" ServerName example1.localhost.com </VirtualHost>
- and following code to your Hosts file
127.0.0.1 example1.localhost.com
- To create multiple Subdomain in localhost using Apache Xampp, repeat step 13 & Step 14
If you like this, please share this to social networks. Have a nice day!