How to change localhost to domain name in xampp

by Yogi P - May 22, 2022

Change localhost to domain name in xampp

Let us change localhost to custom domain name in XAMPP server step by step –

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.

For example you can find this file in this folder here -> ( F:\xampp\apache\conf\extra )
Once you locate the file then edit httpd-vhosts.conf  and add these lines of code and save the file

 

<VirtualHost *:80>

ServerName yourdomainname.com

ServerAlias www.yourdomainname.com

DocumentRoot e:/xampp/htdocs/your-website-root-folder-name

</VirtualHost>

( Replace www.yourdomainname.com with your required domain name )

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.

Share on: Share YogiRaj B.Ed Study Notes on twitter Share YogiRaj B.Ed Study Notes on facebook Share YogiRaj B.Ed Study Notes on WhatsApp
Latest Posts

CDMA Full Form

April 19, 2024

Table of 14

April 11, 2024

Tables 11 to 20

March 11, 2024

Tense Chart

December 22, 2023

Table of 13

December 20, 2023
Search this Blog
Categories

Some important study notes