Add Domain Or Subdomain In Your Localhost Xampp Server

Add Domain Or Subdomain In Your Localhost Xampp Server

We will learn how to build a domain or a subdomain on our localhost Xampp server for php in today’s article.

We’ll break it down into two parts.

We will register our domain/subdomain with the server in step 1 and build a subdomain in step 2.

 Don’t worry, we’re not going to acquire any domains or anything; we’ll do everything on our Windows OS.

So let’s get started by following the instructions below:- :-

Register our domain/subdomain to the server 

  1. Open File Manager using admin
  2. Go to C drive 
  3. In the C drive go to Windows folder then System32 folder
  4. After that go to the  drivers folder and then etc folder.

Now we have arrived to “C:\Windows\System32\drivers\etc”  folder

Domain or subdomain
  1. Open hosts file
If you are unable to edit hosts file then you have to change the permission of the file. To change the permission just follow the below steps
  • Right click on the file
  • Go to properties
  • Go to security
  • Click on Edit
  • Then in Full control column check the checkbox below allow
  • Then click on ok
  • Then follow the step 6
  1. Paste the  following code at bottom of the page
127.0.0.1   test.local    // This will be your reistered domain to the system

Now we will create a Subdomain/Domain

  1. Navigate to the folder where Xampp is installed.
  2. Then go to the folder apache
  3. Then go to the folder conf
  4. Then go to the folder extra
  5. Now our folder path will be 

“xampp\apache\conf\extra”

 

httpd-vhosts file
  1. Now open the file httpd-vhosts and past the following code

 

        
            DocumentRoot “C:\xampp\htdocs\foldername”
            ServerName test.local
        
 

Now we have successfully created the domain in our system.

The last step is to restart the xampp server and enjoy domain in your pc.

 

Please comment below for any help.

Leave A Comment

Your email address will not be published. Required fields are marked *