How to Set Up a Custom Domain Name for XAMPP/WAMP on Windows

Switch from localhost to custom domain in XAMPP/WAMP on Windows. Learn how to set up your local website with a personalized domain name.
Free vector cloud hosting concept illustration
Free vector cloud hosting concept illustration. Image by Freepik / @storyset.

Would you like to configure a custom domain name for your XAMPP/WAMP server on a Windows system? Follow these steps to make the switch from "localhost" to your desired domain:

Update the Hosts File:

  • Locate the "hosts" file on your computer. Typically, it is located in "C:\Windows\System32\drivers\etc\".
  • Open the file using a text editor with administrator privileges (e.g., Notepad with "Run as administrator").
  • Add a new entry at the end of the file in this format: "", where "" is the custom domain you want to use.
  • Save the changes and close the text editor.

Configure XAMPP/WAMP:

  • For XAMPP, navigate to the "httpd-vhosts.conf" file. It is usually located in "C:\xampp\apache\conf\extra\".
  • For WAMP, look for the "httpd-vhosts.conf" file in "C:\wamp\bin\apache\apacheX.X.X\conf\extra\", where "X.X.X" represents the Apache version number.
  • Open the "httpd-vhosts.conf" file with a text editor.
  • Add a new virtual host entry to map your custom domain to the local server. The entry should look like this:
  <VirtualHost *:80>
  DocumentRoot "C:/xampp/htdocs"  # Adjust this path if you have a different document root

Save your modifications and then proceed to close the text editor.

Restart Apache:

  • Open XAMPP/WAMP control panel and stop Apache.
  • Start Apache again to apply the changes.

Update the Windows DNS Resolver Cache:

  • Open Command Prompt with administrator privileges (search for "cmd," right-click, and choose "Run as administrator").
  • Enter the following command to flush the DNS resolver cache:
ipconfig /flushdns

Test Your Custom Domain:

  • Open a web browser and enter "" (replace "" with your actual custom domain) in the address bar.
  • If everything is set up correctly, you should see your local website served by XAMPP/WAMP under the custom domain.

While it is possible to create a domain name similar to "localhost" without any extensions, experts recommend utilizing ".local" or ".test" extensions to minimize the risk of conflicts. Implementing these extensions ensures a more secure and trouble-free configuration.

Remember that this configuration is local and will only work on your machine. To access your custom domain from other devices, you'll need to set up DNS resolution or make appropriate changes to the "hosts" file on those devices.

Congratulations! You have successfully changed your XAMPP/WAMP server's domain from "localhost" to a custom domain name on your Windows system.

About the Author

With over a decade of dedicated experience in the realm of web development, I am a seasoned professional proficient in a diverse array of technologies. Since embarking on this journey in 2009, I have honed my expertise in HTML, PHP, CSS, and JavaScr…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.