How to Create a Sub Domain in Localhost using Xampp

AuthorSumit Dey Sarkar

Pubish Date08 Nov 2022

categoryLaravel

In this tutorial we will learn how to create a subdomain in localhost server using xampp.

 

How to Create a Sub Domain in Localhost using Xampp

 

How to create a subdomain in localhost server using xampp

Let's see all the steps to add subdomain on localhost URL using Xampp (Create subdomain on localhost using xampp).

 

Step 1- Go to httpd-vhosts.conf file in your xampp directory.

In this step add your desired subdomain like below to setting up subdomain on localhost.

C:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "c:/xampp/htdocs"
    ServerName localhost
    <Directory  "c:/xampp/htdocs">
       Require all granted
    </Directory>
</VirtualHost>
 
<VirtualHost *:80>
    DocumentRoot "c:/xampp/htdocs/teknowize"
    ServerName teknowize.localhost
    <Directory  "c:/xampp/htdocs/teknowize">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

 

Step 2- Create new directory for subdomain in htdocs folder.

Here, we are created a teknowize directory in htdocs folder to access the files.

 

Step 3- Create index.php file

Now, create a index.php file to run the page on subdomain.

C:\xampp\htdocs\teknowize\index.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Welcome to teknowize.localhost</h1>
</body>
</html>

 

Step 4- Restart xampp server

 

Output

Laravel

 

Note: All the above steps are also used to setting-up Multiple Subdomains in Localhost Using Xampp.

 

Comments 0

Leave a comment