The sounds like crazy right ? yes it is, rename localhost to a domain in xampp is for some craze. Ok lets check how we can achieve rename localhost to a domain name. The steps are simple and easy only few things for changing your localhost to a domain name.
First you have to open two files in the following directories. The file names are httpd-vhosts.conf in apache folder and host in windows folder.Step 1 :
//The httpd-vhosts.conf file you can find in the following path .The drive here is "C" that will change according to your installation. C:\xampp\apache\conf\extra\
Open the Above file and add the following codes at the end of the file.You have to edit this file using notepad or notepadd++ not open it in word or any other modern document it may messed up the characters and encoding. Here Iam changing my localhost to “dreamdevelopers.com”
<VirtualHost *:80> ServerName www.dreamdevelopers.com ServerAlias dreamdevelopers.com DocumentRoot c:/xampp/htdocs/ </VirtualHost>
Then save the file and the follow next stepStep 2 :
Now you configure the domain name in apache services then you need to edit the host file of windows for DNS look up check the following file path and open the file.
//The host file you can find in the following path in most Operating system Win7/xp/Vista C:\WINDOWS\system32\drivers\etc
Open the file and follow the steps. just need to change # from the beginning and add you domain name instead of follows.
# localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost
The above section you have to modify as follows.
# localhost name resolution is handled within DNS itself. 127.0.0.1 dreamdevelopers.com ::1 dreamdevelopers.com
Then save the file and restart your Apache server and mysql. Now see the magic . 🙂
Did you face any difficulties to stop and start Apache services like error “apache not stop error -1” try this method.
Start Run Type services.msc Find the Apache and mysql services Right click and stop , or restart
Also you may face issue with permission on host file editing and saving, you can only do this if you are an admin user. If you are admin and still the issue try this.
Copy your existing host file to any other location like d:\ then make edit on it and paste back to same folder
You have take a backup for host file before doing this.
enjoy localhost with any domain name 🙂 🙂 🙂