问题原文
原帖链接 · Tony DiNitto · CC BY-SA 3.0
I'm moving hosts over to a shared host (HostGator) and trying to access my site before DNS propagation has completed, so I can access my WP-ADMIN (which can't be done w/ temporary URLs).
I'm told that editing my HOSTS file (w/ the domain name and new IP) will allow me to access it prior to migration. But what's the difference between doing that and just skipping altering HOSTS typing in the IP address directly?
I feel like I'm missing some fundamental beyond "DNS takes a name and translates to an IP address." b/c typing in an IP clearly isn't the exact same as typing a domain. Example - I ping StackOverflow, HostGator, and Google and go to their respective IP addresses I get: "Error 103", "Error 404", and no error at all, respectively.
Ultimately, I just want into my WP-ADMIN before propagation is complete. I've updated HOSTS and my computer seems to bypass looking at it (Windows 10 using FF, Edge, Chrome. One space between domain and IP. Hosts file has no extension. Registry entry for HOSTS points at the system32/drivers/etc folder correctly. I even updated the lesser known HOSTS found in - C:\Windows\WinSxS\amd64_microsoft-windows-w..ucture-other-minwin_31bf3856ad364e35_10.0.10586.0_none_c1c535cf0f692563).
Before I keep endlessly troubleshooting why my HOSTS file is being ignored, I'd like to know if a) that will actually allow me to get into my WP-ADMIN and b) Why (since I'm obviously not understanding something in the DNS fundamentals)?
已采纳解答
原帖链接 · Tony DiNitto · CC BY-SA 3.0
Yes - altering a HOSTS file locally to redirect a domain to an IP isn't the same as simply typing in that IP into the browser. The reason why is that in shared hosting, one IP address houses multiple domains. When you type in that IP address of "your" site (which is also the IP of other sites as well), the server can either a) Give an error b/c it doesn't know which domain should be associated with that IP or b) Go to one of the sites that has that IP the server picks in some way.
The reason why is that the IP address hits the server, the virtual hosts that are serving multiple sites will also look in your HTTP header request (from your browser) to know which specific hostname to query. Since an IP address lacks this extra bit of info (the hostname), the server will give back an error. Altering the HOSTS file fixes this, since it 'carries' with it that hostname in the header now.
Rather than continue to struggle endlessly with altering my HOSTS file. I found it much easier/faster, and just as effective, to download the Virtual Hosts plug-in for Chrome which edits the HTTP header info upon querying a site. By opening the plug-in and putting in the IP address of the server, and the domain name (the hostname) I'm looking for, the virtual host now knows what to return and works perfectly.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
