Last updated December 6th, 2023 06:20
Do you need to test a website or debug an application on a server that is not pointed to by the domain in DNS? It may seem like a tricky situation if your web hosting provider does not offer a test URL where the website and its content can be seen. However, there is a solution to bypass this on your local computer and view a different server than the one pointed to by the domain in DNS. Here is a simple guide on how to test web hosting without a domain pointing to it.
How to test web hosting without a domain pointing to it? Using the HOSTS file.
The key element through which the above can be accomplished is called the HOSTS file. In the Windows operating system, you can find it in the folder:
C:\Windows\System32\drivers\etc
This file essentially simulates the function of DNS, and its advantage is that any record in it takes priority over real DNS. In simple terms, if you add a domain and its routing to a specific IP address in this file, the system will no longer query DNS for the website associated with that domain, but will instead route it directly to the IP address stored in the HOSTS file.
What does a HOSTS file entry look like?
To modify the HOSTS file, first open it in any text editor. Once the editor is open, you can add routing for a domain.
The basic format looks like this: first, you specify the server’s IP address, and then the domain. To separate the domain from the IP address, you can use the tab key (located above CAPS LOCK). The entry looks like this:
185.129.138.60 test.cz
185.129.138.60 www.test.cz
As you can see from the example above, the first thing you need to specify is the server’s IP address, which is provided by your web hosting provider. After the IP address, you need to add a space using the tab key and then the domain name that you want to test on that server. It’s a good idea to add both versions of the domain to the HOSTS file, with and without the “www” prefix. If your website uses a redirect to one of these two versions, and you haven’t included it in the HOSTS file, you will be redirected to the real website instead of the test one.
Where will you see the domain on the test server?
Only in the locations where the HOSTS file has been modified accordingly. This has one advantage: you can continue routing the domain to the server where your current application or e-shop is running, but on the computer where you have modified the HOSTS file, you can also prepare a presentation on another server. Then, you can simply redirect the domain to that server using DNS. However, be aware that if you want to show the results of your work to someone on the new server, they will also need to modify their HOSTS file. Otherwise, their browser will use the classic DNS and redirect the domain to the IP address of the current server.
I would like to add an important note. If you modify the HOSTS file, it is recommended to use a browser with cleared temporary files or use an anonymous mode to view the website. This will prevent problems where the browser doesn’t show the real data on the server. Instead, the browser will use the cache to display the website, and even with the modified HOSTS file, it will show the original data fetched from the cache memory.
The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.
Byl pro Vás tento článek užitečný?
Klikni na počet hvězd pro hlasování.
Průměrné hodnocení. 0 / 5. Počet hlasování: 0
Zatím nehodnoceno! Buďte první
Je mi líto, že pro Vás nebyl článek užitečný.
Jak mohu vylepšit článek?
Řekněte mi, jak jej mohu zlepšit.
Subscribe to the Newsletter
Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.