When you test websites on local machine using a server environment program, such as XAMPP, WAMP,the website URL is assigned to 127.0.0.1 and/or localhost. Sometimes however you may want to change the localhost name or local server address to a test development domain name like mysite.com, website.dev.
In an earlier article, we discussed how you can change localhost to domain name for XAMPP server by editing the hosts file for your local machine and add the custom domain to a configuration file named httpd-vhosts.conf for XAMPP. With WAMP server, the process is a little bit easier than XAMPP. To change your local IP or localhost to a custom domain name or URL all you need to do is run your wamp server and add a virtual host from there. Check out details below.
Run WAMP server on your PC, wait for a second until WAMP server starts the Apache and MySQL services. Then visit 127.0.0.1 to open WAMP server home page in a web browser on your computer. The Tools section can be found at the left bottom corner of WAMP server home page. Find and click to open Add A Virtual Host from there. You will then be guided to the following page.
To add a virtualhost or custom domain to WAMP server is very easy. There are three boxes on this page: Virtual Host name, Local IP address and Virtual Host folder.
- Enter your domain name in the Virtual Host name box without space, underscore or diacritical characters.
- You don’t have to use an IP in the IP address field. Leave it empty.
- The third input field goes to complete absolute path of wamp server. If you have installed WAMP server to the root folder on D drive on your PC, then the absolute path of wamp server will be d:/wamp64/www or d:/wamp/www/.
Finally, click on the Start the creation of the virtual host button to add your own domain to wamp server. It may take a while to complete. After that, go to restart DNS, Apache service or the wamp server to let the change take effect.
Now open your browser and type your custom domain name to open the wamp server home page.