Attempting to redirect webpage to local html file, does not launch html file

2

Just out of curiousity I'm attempting to redirect 'www.google.com' to a local html file on my pc. As in every attempt of loading google.com, it would instead boot up the html file.

The html file works fine when loaded manually by my clicking it, but when I attempt to use chrome extentions (switcharoo or requestly), nothing happens.

Do I need to host the page on a local server for the redirect to work?

Eric

Posted 2014-12-31T19:45:51.233

Reputation: 83

2what url format did you use? file://.... – rob – 2014-12-31T21:48:09.293

Answers

0

When you make a request in a browser the normal process (in short) is to send a request to a DNS server to ask 'Where is google.com?' the DNS server then replies and says 'google.com is at 8.8.8.8 (or whatever IP it is on). Your web browser sends a request for data to that IP address and returns that page in your browser.

You can use your hosts file to create a local set of ip resolutions (ie. before the browser asks the DNS server which IP address the website is on it looks for an entry in your hosts file to see if you have specified one first)

The first step - apart from making your cloned html file - is to set an entry in your hosts file to have a line that says:

google.com 127.0.0.1

This will say to look to your localhost to resolve requests to google.com

However, this still doesn't fix your issue. You do need to be running a server (preferably on port 80) in order for your hostfile redirect to work (otherwise the browser won't receive responses to requests for page requested)

Definitely look in to some local webserver options and modify your question with further information based on how far you can get now.

Hope this helps!

Abraxas

Posted 2014-12-31T19:45:51.233

Reputation: 3 704