How to Set a Domain name for xampp server project like: example.com

If you want to give a domain name for your Xampp Project, YES! Here you Can do it easily… Just Follow the Below Steps-

Step-1:

Open Your XAMPP Folder, Where You Have Installed.

Then, Go to folder apache,

Then, Open Folder conf,

Then, Open Folder extra.

The Full Path is Like,

PATH::    C:\xampp\apache\conf\extra

Now, Open “httpd-vhosts.conf” in an Editor

FILE NAME:: httpd-vhosts.conf
open file named – httpd-vhosts.conf

Here, You can see the line of code, Like-


#Virtual Hosts
#
#Required modules: mod_log_config
#If you want to maintain multiple domains/hostnames on your
#machine you can setup VirtualHost containers for them. Most configurations
#use only name-based virtual hosts so the server doesn't need to worry about
#IP addresses. This is indicated by the asterisks in the directives below.
#
#Please see the documentation at

#for further details before you try to setup virtual hosts.
#
#You may use the command line option '-S' to verify your virtual host
configuration.
#Use name-based virtual hosting.

#NameVirtualHost *:80
#VirtualHost example:
#Almost any Apache directive may go into a VirtualHost container.
#The first VirtualHost section is used for all requests that do not
#match a ##ServerName or ##ServerAlias in any block.
#

##ServerAdmin [email protected]
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common


##ServerAdmin [email protected]
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common


Here, at the End of file just add the below code. here example.com is your project domain name. You Can change it as you want..


ServerAdmin [email protected]
DocumentRoot "C:/xampp/htdocs/example.com"
ServerName example.com
ErrorLog "logs/example.com-error.log"
CustomLog "logs/example.com-access.log" common

Step-2:

Now, Open your C drive’s – Windows Folder,

Then, Open System32 Folder,

Then, Open drivers folder,

Then, Open etc folder,

Here, you can find many files. From here Open “hosts” file in an Editor.

PATH::    C:\Windows\System32\drivers\etc
FILE NAME:: hosts

The hosts file content look like – 

Copyright (c) 1993-2009 Microsoft Corp.
#This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names.
#Each entry should be kept on an individual line.
#The IP address should be placed in the first column followed by the corresponding host name.
#The IP address and the host name should be separated by at least one
space.
#Additionally, comments (such as these) may be inserted on individual
lines or following the machine name denoted by a '#' symbol.

#For example:
#102.54.94.97 rhino.acme.com # source server
#38.25.63.10 x.acme.com # x client host

#localhost name resolution is handled within DNS itself.
#127.0.0.1 localhost
#::1 localhost

# Newly Added Project Domain
127.0.0.1 example.com

Here, you can see newly added domain. It is the project domain which we have created in xammp folder in Step-1


127.0.0.1 example.com

Now, Restart your xampp,

Now you can access the project using the domain name.

Now , Just type your given domain name or example.com, the project fill will open.

Finally Done. 

Leave a Comment