Add Domain Name in Windows

How to Add a Domain Name in Windows

For testing websites you can add a domain name in Windows by editing the Windows hosts file and the local webserver's hosts file.

The domain name may be anything you like, but try to avoid using a name that you may need to access on the web. An easy way to do this is by making up a TLD such as .test rather than say .com

Mappings of domain names to the local machine IP address are contained in the hosts file.

How to Edit the Windows Hosts File

The Windows hosts file is usually located as a hidden file in the folder C:\\Windows\\System32\\drivers\\etc\\

To view hidden files in Windows 7, you can change the settings via the start menu as follows:
Control Panel -> Appearance and Personalization -> Folder Options -> View -> Advanced settings -> Show hidden files, folders, and drives

Rather than navigating all the way through this chain of menu items, you can simply enter "hidden" into the search box.

To edit the hosts file, you need to start your text editor in administrator mode. You can do this by right-clicking on the Notepad icon and selecting "Run as administrator".
Locate the C:\\Windows\\System32\\drivers\\etc\\ folder and choose to view "All Files (*.*)".

Now you should see the "hosts" file in the file list. Open the file to see existing mappings of the local host IP address (127.0.0.1) to host names.

Now add your new domain to the list e.g. 127.0.0.1    mysite.test

You can add as many new domains as you like to the list.

Save the file. Now the computer will recognize the domain mysite.test as a locally-hosted domain. There is no need to reboot your PC.

In order to view the home page in a web browser, you now need to configure your local machine web server.

The web server needs to be configured so that it maps the domain to a document root on your computer.

No comments:

Post a Comment