KNOWNHOST WIKI

User Tools

Site Tools


dns:how-can-i-test-my-migrated-website-before-changing-the-dns

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dns:how-can-i-test-my-migrated-website-before-changing-the-dns [2019/10/11 08:27]
Karson N.
dns:how-can-i-test-my-migrated-website-before-changing-the-dns [2020/06/02 07:49] (current)
Karson N.
Line 3: Line 3:
 The recommended method of testing websites before changing DNS for a domain is to edit the local **__hosts__** file on your computer. ​ This will bypass the DNS lookup from your computer to that domain -- allowing your computer to "​see"​ the site as it is in your new service without making any changes to the site or the service. The recommended method of testing websites before changing DNS for a domain is to edit the local **__hosts__** file on your computer. ​ This will bypass the DNS lookup from your computer to that domain -- allowing your computer to "​see"​ the site as it is in your new service without making any changes to the site or the service.
  
 +\\
 ===== How to edit your local "​hosts"​ file ===== ===== How to edit your local "​hosts"​ file =====
  
Line 9: Line 10:
 This is the **preferred method** to test your site, as many sites (and most common site software such as WordPress) use Apache mod_rewrite rules -- other methods of testing a site before changing DNS can interfere with the way these rules allow your site to work. This method is a bit in-depth and requires some working knowledge of your operating system. I will attempt to break it down as much as possible. This is the **preferred method** to test your site, as many sites (and most common site software such as WordPress) use Apache mod_rewrite rules -- other methods of testing a site before changing DNS can interfere with the way these rules allow your site to work. This method is a bit in-depth and requires some working knowledge of your operating system. I will attempt to break it down as much as possible.
  
 +\\
 ==== Windows Operating Systems ==== ==== Windows Operating Systems ====
  
Line 18: Line 20:
     * ''​127.0.0.1 localhost''​     * ''​127.0.0.1 localhost''​
   - You can add additional lines to this file that will point requests for a particular domain to your new server'​s IP address. Example:   - You can add additional lines to this file that will point requests for a particular domain to your new server'​s IP address. Example:
-    *<​code>​127.0.0.1 localhost+<​code>​ 
 +  ​127.0.0.1 localhost 
 + 
 +  67.222.1.2 example.com 
 +  67.222.1.2 www.example.com 
 +</​code>​
  
-67.222.1.2 example.com 
-67.222.1.2 www.example.com</​code>​ 
   - Save your changes.   - Save your changes.
   - Restart any currently open browsers. You may also want to flush your DNS cache. In most versions of Windows, you do this by running the following command from within the command prompt:   - Restart any currently open browsers. You may also want to flush your DNS cache. In most versions of Windows, you do this by running the following command from within the command prompt:
Line 27: Line 32:
   - Visit the migrated version of your website by visiting www.example.com or http://​example.com in your browser window.   - Visit the migrated version of your website by visiting www.example.com or http://​example.com in your browser window.
  
 +\\
 ==== Mac Operating Systems ==== ==== Mac Operating Systems ====
  
   - Open the "​Terminal"​ application. ​   - Open the "​Terminal"​ application. ​
   - Use the nano application,​ with sudo, to modify the /etc/hosts file. //(You will be prompted for your password for sudo access.)//   - Use the nano application,​ with sudo, to modify the /etc/hosts file. //(You will be prompted for your password for sudo access.)//
-    * <​code>​sudo nano /​etc/​hosts</​code>​+<​code>​ 
 +  ​sudo nano /etc/hosts 
 +</​code>​ 
   - Just as with the Windows steps, you can add additional lines to this file that will point requests for a particular domain to your new server'​s IP address. Example:   - Just as with the Windows steps, you can add additional lines to this file that will point requests for a particular domain to your new server'​s IP address. Example:
-    *<​code>​127.0.0.1 localhost+<​code>​ 
 +  ​127.0.0.1 localhost 
 +  67.222.1.2 example.com 
 +  67.222.1.2 www.example.com 
 +</​code>​ 
 + 
 +{{:​dns:​mac-os-terminal-local-hosts.png?​nolink&​1200|}}
  
-67.222.1.2 example.com 
-67.222.1.2 www.example.com</​code>​ 
-    * {{:​dns:​mac-os-terminal-local-hosts.png?​nolink&​800|}} 
   - Once you make your changes, type [CTRL] + X to save the file.   - Once you make your changes, type [CTRL] + X to save the file.
-  - One last step to clear your cache and make the new settings take place. ​Run the following command while still in terminal+  - One last step to clear your cache and make the new settings take place. ​ ​You'​ll need to flush DNS, and the instructions will vary depending on your version of MacOS
-    ​<​code>​dscacheutil -flushcache</​code>​+    ​- El Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14), and Catalina (10.15) 
 + 
 +<​code ​bash> 
 +  sudo killall -HUP mDNSResponder 
 +</​code>​ 
 + 
 +    - Yosemite (10.10) 
 + 
 +<code bash> 
 +  sudo discoveryutil udnsflushcaches 
 +</​code>​ 
 + 
 +    - Lion (10.7), Mountain Lion (10.8), and Mavericks (10.9) 
 + 
 +<code bash> 
 +  sudo killall -HUP mDNSResponder 
 +</​code>​ 
 + 
 +    - Snow Leopard (10.6) 
 + 
 +<code bash> 
 +  ​dscacheutil -flushcache 
 +</​code>​
  
 +\\
 ==== Video Tutorials ==== ==== Video Tutorials ====
  
 {{youtube>​1vp1cIVbj8M?​large |Edit Local hosts file on Windows 7}}  {{youtube>​1vp1cIVbj8M?​large |Edit Local hosts file on Windows 7}} 
  
dns/how-can-i-test-my-migrated-website-before-changing-the-dns.1570800452.txt.gz · Last modified: 2019/10/11 08:27 by Karson N.