Home Blog WordPress Management How and Why to Use The Windows Hosts File

How and Why to Use the Windows Hosts File

How and Why to Use The Windows Hosts File

The Windows hosts file can be used to redirect requests from your computer to a website to another IP rather than the original IP or domain. In other words, if I want to run a test copy of the website www.melapress.com on my laptop, I configure a lightweight web server on my computer and simply add an entry in the Windows Host File to point www.melapress.com to 127.0.0.1 (localhost).

By adding such entry all the requests being sent from my computer to www.melapress.com are redirected to the web server running on my laptop rather than to the live website. This kind of scenario is ideal when testing website changes or new website features. Instead of making changes on the live website at the risk of breaking it, you can setup a local copy of the website using a XAMPP server to test the changes before applying them on the live website.

How to add entries to Windows Hosts file

  1. The Windows Host file is called hosts (without any file extension) and can be found in the following directory: C:WindowsSystem32driversetc
  2. To open the file, right click it and select ‘Open with’ option from the right click menu.
  3. Select notepad or any other text editor of choice to modify such file
  4. To redirect all the traffic from your computer to your website to the test website on XAMPP web server running on your own computer, add the following line at the end of the hosts file:
127.0.0.1              www.yourwebsite.com

In my case, to access my test copy of the website www.WP White Security.com running on my local computer, I add the below entry to the Windows hosts file.

127.0.0.1              www.WP White Security.com
  1. Once you update the Windows hosts file, proceed with the testing.
  2. Once ready from the testing, don’t forget to delete the entry from the Windows hosts file to be able to access the live website again.

Melapress Blogger Tip: You might need to restart your web browser (such as Chrome) for the Windows Hosts file changes to take affect.


2 thoughts on “How and Why to Use The Windows Hosts File

  1. Hello,
    I am new to web development and I need help. I would like to have 3 to 4 WordPress websites on my computer.
    I have Windows 7, Xampp portable lite, Notepad++, and the most current version of WordPress.
    My Xampp and WordPress are stored on an external harddrive. I have tried understanding this reconfiguring stuff, but I get lost.
    For starters – Do I have to have my Xampp and WordPress on my “C” drive in order to have more than one site?
    Do you know where I can get a step by step tutorial, for a novice?
    Thank You for any possible help, Sincerely,
    – Fritz


Leave a Reply

Your email address will not be published. Required fields are marked *

Stay in the loop

Subscribe to the Melapress newsletter and receive curated WordPress management and security tips and content.

Newsletter icon

It’s free and you can unsubscribe whenever you want. Check our blog for a taste.

Envelope icon
Uploading WP 2FA as a zip file in WordPress
WP 2FA in the WordPress plugin repository
Close

Installing WP 2FA Free

Congratulations on taking the first step towards enhancing your WordPress site's security with WP 2FA Free! You're now on your way to protecting your valuable data and ensuring peace of mind. No coding or technical knowledge is required.

 

Below are two ways to install WP 2FA on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for WP 2FA.

Download the WP 2FA plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading CAPTCHA 4WP as a zip file in WordPress
CAPTCHA 4WP in the WordPress plugin repository
Close

Installing CAPTCHA 4WP Free

Well done you. You're one step closer to safeguarding your WordPress website from spam and automated attacks with CAPTCHA 4WP. You'll be able to effortlessly integrate CAPTCHA into your forms and enjoy a website with enhanced security.

 

Below are two ways to install CAPTCHA 4WP on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for CAPTCHA 4WP.

Download the CAPTCHA 4WP plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP Activity Log as a zip file in WordPress
WP Activity Log in the WordPress plugin repository
Close

Installing WP Activity Log Free on your website

You deserve a pat on the back for choosing to record user actions and changes on your website. That is the first step towards better user accountability, easier troubleshooting of website security, and many other benefits of issues.

 

Below are the two ways to install WP Activity Log on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for WP Activity Log.

Download the WP Activity Log plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading Melapress Login Security as a zip file in WordPress
Melapress Login Security in the WordPress plugin repository
Close

Installing Melapress Login Security Free

Congratulations on taking control of your WordPress website's security by implementing robust login and password policies with Melapress Login Security. You can change your login page URL, limit failed login attempts, and reset passwords.

 

Below are two ways to install Melapress Login Security on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for Melapress Login Security.

Download the Melapress Login Security plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2