Skip to content

How to Change localhost to a Custom Domain Name in XAMPP/WAMP (Windows)?

Changing localhost to custom domain name in XAMPP & WAMP

Domain names are always easy to remember and also give a professional look in local development instead of typing IP (127.0.0.1) or localhost and file directory.

By default while using local development server WAMP and XAMPP, you have to type localhost/{directory_of_web_application} or 127.0.0.1/{directory_of_web_application} in browser. In XAMPP/WAMP, there is no direct one-click method like in localWP to create a custom domain.

This tutorial will help you to create an easy-to-use custom domain URL in WAMP and XAMPP.

Let’s say you have your local application on localhost/mylocalapp. After following this tutorial you can access that application with mylocalapp.test or any domain name you would like.

Steps to convert localhost into a custom domain in XAMPP in Windows

To set up a custom domain in localhost we have to apply the change in three places: Setting local development in XAMPP & identifying directory, pointing a custom domain to local computer from Windows host file, and redirecting the domain to a specific application folder through VirtualHost.

Locate Application directory (folder)

Generally, application/website files are located inside htdocs in the main XAMPP folder. For localhost/mylocalapp directory C:/xampp/htdocs/mylocalapp.

Update Windows Host file

Now, Update the Windows host file to tell the local DNS to redirect your domain into your local computer (same Computer).

  • Step 1: Go to C:\Windows\System32\drivers\etc and edit hosts file “as Administrator”. [ For that open, any text editor in administrator mode then navigate to hosts file.]
  • Step 2: Add 127.0.0.1 and custom domain at the end of file.
127.0.0.1   mylocalapp.test mylocalapp.local

You can add as many domain names as you want by separating them with space. Or can add on each new line like: 127.0.0.1 mylocalapp.local

  • Step 3: Save and close.

After getting a request on the same localhost server, let’s tell which application to execute on a particular domain request with a virtual host.

Update Apache virtual host.

Virtual host redirects a particular domain to a specific application file directory in the server.

  • Step 1: Go to C:\xampp\apache\conf\extra and open httpd-vhosts.conf file.
  • Step 2: Add virtual host configuration for particular URL at the end of file.
<VirtualHost *:80>
    ServerName mylocalapp.test // URl to set
    ServerAlias mylocalapp.local // Another URl to open same Web App
    DocumentRoot C:/xampp/htdocs/mylocalapp // Application file directory (folder) in XAMPP localhost
</VirtualHost>

You can add multiple alias names (domain name) by separating with space or can add another ServerAlias line in the new line.

  • Step 3: Save and close.

Now, your custom domain for local applications is ready.

Find More:

Steps to convert localhost into a custom domain in WAMP in Windows

Now, we can easily add a custom domain in WAMP from Graphical Interface.

  • After starting WAMP server, visit localhost in browser and click “Add a Virtual Host” on left bottom corner.
Changing localhost to custom domain in WAMP server
  • Then, add custom domain in “Name of Virtual Host” field and your local application folder path in “VirtualHost folder” field. And, click on “Start the creation of the VirtualHost”.
Adding custom domain to WAMP Virtual host
  • Now, restart the DNS server. Right click on WAMPserver icon on taskbar tray. Go to Tools and click on “Restart DNS”. Now your custom domain is configured an ready to use.

Why should you use .local & .test instead of .com domain in localhost?

When using already available domain extension suffixes like .com, .net, .dev, and more, there is a chance domain may already be registered and hosted on the internet and may conflict while browsing these real domains with your local setup.

So, it’s always better to use .local and .test in the local test environment as they are special-use domain names reserved by the IETF (Internet Engineering Task Force) for these scenarios and can’t be registered in the domain registrar.


If you have any confusion following this tutorial or any topics on Nil Tutorial, don’t hesitate to ask in the comment section. You can also reach me on Twitter.

9 thoughts on “How to Change localhost to a Custom Domain Name in XAMPP/WAMP (Windows)?”

    1. You can create a domain name like localhost without an extension but it’s recommended to use .local and .test extensions to prevent possible conflict.

    1. Configure DNS A record mapping your domain into IP. You can manage DNS in the domain registrar panel. Also, you can use third-party nameservers like Cloudflare.

  1. If I configure my domain name on my computer, which means it’s not accessible from anyone from the internet? Outside from the internet, If they want to access my content locally on my computer then I’ll have to supply them my pubic IP address (assuming I already configured my localhost to do so).

    1. Yes, that is one way. You can also create a live URL for your local project using tools like the live link option of localwp. Some other tools and services also provide this feature: ngrok, localtunnel, BrowserStack, PageKite, boringproxy.

Leave a Reply

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