Change localhost to domain name in xampp
Step 1. Amend hosts file in windows
Open the hosts file located in folder at C:\Windows\System32\drivers\etc and right click hosts file and select edit “as Administrator” . Now add these line of codes in it and save the file –
127.0.0.1 www.yourdomainname.com
( Replace www.yourdomainname.com with your required domain name )
Step 2. Edit httpd-vhosts.conf file in XAMPP installation.
<VirtualHost *:80>
ServerName yourdomainname.com
ServerAlias www.yourdomainname.com
DocumentRoot e:/xampp/htdocs/your-website-root-folder-name
</VirtualHost>
Step 3. If you want to access your site over https edit httpd-vhosts.conf file
You can find this file in this folder here -> ( F:\xampp\apache\conf\extra ).
To make a site to load over https you need to add below line to httpd-vhosts.conf
<VirtualHost_default_:443>
DocumentRoot "e:/xampp/htdocs/your-website-root-folder-name"
ServerName www.yourdomainname.com:443
ServerAlias yourdomainname.com:443
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
</VirtualHost>
Note: Add proper ssl certificates to make it secure
Step 3. Now restart XAMPP and check the setup.
Now test it by visiting www.yourdomainname.com domain you set up. If you followed the steps carefully, you should be able to see the content of the site in your browser.