I know you can edit a hosts file to redirect a URL to an IP address as so:
127.0.0.1 google.com
but how do you force a redirect to a URL instead of an IP address?
e.g.
mysite.com/welcome.aspx google.com
The explicit URL doesn't work and assuming mysite.com's IP is 222.222.222.222, the following doesn't work either:
222.222.222.222/welcome.aspx google.com
Inserting a redirect into the hosts file is simple. Just enter the IP address of the desired server or host, leave a single space, and then enter the domain or hostname you want to point to that IP. Enter only one redirect per line.
Modifying your hosts file causes your local machine to look directly at the Internet Protocol (IP) address that you specify. Rackspace offers managed hosting solutions to assist with the handling of these resources.
To Unblock Websites Blocked in the Hosts File, Navigate to the folder C:\Windows\System32\drivers\etc. Select "All Files" from the drop-down menu. Double-click the hosts file. Add the comment symbol # at the beginning of the line that contains the blocked web site you want to unblock.
No, but you could open a web server at, for example, 127.0.0.77 and use it to check if the Request URI is "/welcome.aspx"... If yes redirect to google, if not load the original site.
127.0.0.77 mysite.com
You can't. A redirect requires a webserver to accept the first request and send back the redirect. The "hosts" file just lets you set your own DNS records.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With