Will altering my HOSTS file allow me to access sites that can't be directly accessed via IP?
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.
The short answer is yes.
Adding the domain name and IP to your HOSTS file will resolve the domain, locally, to the IP you have entered. When you then visit that domain in your web browser, along with your request to the web server (at that IP address you entered), your browser will send the domain name you have requested. The shared web server will then use this to display the correct web site to you.
Using your HOSTS file is pretty much just like delegating your domain name - only the changes can only been seen locally.
EDIT: some additional help
If you'd like to post your HOSTS file contents, we might be able to help troubleshoot why that's not working as well. One thing, make sure you've cleared your browser cache in case that is caching the DNS.
Also, if you want to avoid the whole HOSTS file thing entirely, you can use the temporary URLs to get into wp-admin
. If you edit your database, in the wp_options
table you just need to change the site_url
and home_url
values to your temporary URL to stop wp-admin
from automatically redirecting you.