【local host】修改以测试还未上线的网站

Sometimes when designing a new web site, you may need to test certain aspects of the site before launching the site live to the general public. This Article will describe how to test your application without a registered domain name. 
 
1> What is the host file on your local computer ? 
 
Simply put, the Hosts file is similar to an address book. Exactly like the example above, when you type an address like www.domain.com into your web browser, the Hosts file on your own computer is referenced to see if you have the IP address for that web site. If you do, then your computer will use that IP it has on file locally to “call” and the corresponding web site opens. If not, your computer will ask the DNS Server belonging to your Internet Service Provider for the associated IP address for the corresponding web site and connects you to that web site. The majority of the time, you will not have all the IP Addresses of all the web sites from the entire Internet in your “address book”. You will probably have very few (if any) entries within your Local Hosts file. Therefore, most of the time your computer will ask for the IP addresses of web sites you wish to visit from your ISP.
 
2> The principle to edit the host files to get your test site loading on your own computer ? 
 
By editing your local Hosts file, you can affect what happens when you type in a certain web site address on your own system by redirecting the web browsers on your computer to the web server to view that particular site than the rest of the world would see. So while the rest of the users of the Internet type “www.domain.com” into their web browsers and get redirected to the web server at the IP address which with DNS records propagated, visiting the same “www.domain.com” web address on YOUR own computer only could bring you to the IP address of your testing web server.Once you are done testing your site, you could then edit your local Host file again to connect to the site as a regular Internet user would.
 
 

To test your web site using your own domain name BEFORE DNS propagation has completed, you can use your local computer’s HOSTS file. Your computer will use the entries in your HOSTS file FIRST before it tries to use your IPS to look up the DNS information for your domain.

REMEMBER: When you are finished testing, remember to remove the custom lines that you added to your Hosts file.

3> Below is the steps to edit hosts file on your PC. 

  1. Launch NotePad
    Click on your Windows icon in the Task Bar in the bottom left hand corner of your screen.
    In the “search” field, type “Notepad”. A list of entries will appear.
    IMPORTANT (Windows 7 and later): Right-click on Notepad choice found and select “Run as Administrator “. If you don’t have the run as Administrator option it means you don’t have these privileges. Contact your IT person to get them or to set up the local host for you.
  2. Open your local HOST file
    Within Notepad go to File Menu->Open and locate the HOSTS file on your computer.IMPORTANT: In the bottom right hand corner of the Open dialog box, change the popupmenu FROM “Text Documents (*.txt)” TO “All Files”
    Typically it is in one of the following locations:
    • Windows NT/2000/XP/2003/Vista/7/8/10 – C:windows/system32/drivers/etc/hosts
    • Windows 95/98/Me – C:windowshosts
    • Consider performing a “Save As” so you have an original copy of the file that you can restore later.
  3. Filename: hosts 
    • You can add additional lines to this file that will point requests for a particular domain to your new server’s IP address.

    • Example:


      Filename: hosts

      127.0.0.1 localhost
      66.186.19.2 www.suetest.com

      Edit to local HOST File
      You will see two columns of information, the first containing IP addresses and the second containing host names. By default, a windows hosts file should be similar to the following:

  4. Save your changes
    IMPORTANT: be sure to save as a host file, NOT as a text (.txt) file
    Windows wants to save it as text (.txt) so you need to
    1. Change “save as” type to “all files”, and then
    2. Click on “host”  (the original file).
  5. Restart any currently open browsers
  6. Flush your DNS Cache
    You may also want to flush your DNS cache. In Windows, go to Start/Windows button in the bottom left of your Task Bar, and in the search field type “cmd” and hit the Enter key on your keyboard.
    Type the following: ipconfig /flushdns
  7. Test your changes
    In your web browser you should see your site as it appears on your testing server when typing http://www.suetest.com/ but still be able to see the site on its current web server by visiting http://www.suetest.com/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值