How to create subdomain on localhost

Some time we need to create subdomain on our localhost or local server. I have also faced this problem so that I am going to share with you that how to create subdomain on localhost. Creating subdomain on your local server is very easy.

Creating subdomain on XAMP or Local Server

If you want to create subdomain on xamp then follow the following instruction.

  • Find the following file on your system

C:\Windows\System32\drivers\etc\hosts

  • Add the following code at the end of the file

# Custom Server and hosts
127.0.0.1 subdomain.localhost.com

  • Now find the following file and open that

xamp\apache\conf\extra\httpd-vhosts

  • Add the following code at the end of this file

  • Now restart your server. You can access your subdomain like http://subdomain.localhost.com