【local host】修改以测试还未上线的网站
2016-04-26 17:16
525 查看
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.
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.
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.
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:
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
Change “save as” type to “all files”, and then
Click on “host” (the original file).
Restart any currently open browsers
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
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/
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.
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.
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.
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:
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
Change “save as” type to “all files”, and then
Click on “host” (the original file).
Restart any currently open browsers
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
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/
相关文章推荐
- Windows Script Host终止的解决方法
- 关于tomcat的server.xml里host节点配置的一些说明
- MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server through socket
- centos中没有host dig nslookup命令的解决办法
- valgrind-3.11.0 交叉编译
- Linux不能上网ping:unknown host出错该怎么办?
- 将centos7打造成桌面系统
- Linux***与提权:技巧总结篇
- 配置lamp排错指南
- mongodb3.0的权限认证问题
- 多版本Python共存,以及pip对应
- Destination Host Unreachable和Destination Net Unreachable
- adb remount bash: /usr/local/bin/adb: Permission denied
- solve ubuntu 9.04 ALERT: /host/ubuntu/disks/root.disk does not exist,Dropping to a shell!
- 不想每次都到: /usr/local/mysql/bin
- 三思—mysql安装配置手册(一)
- 三思—mysql安装配置手册(二)——-my.cnf
- Linux bash Shell中的变量类型详解
- Diff
- sysbench-0.4.12安装注意事项