I know I can map URLs to other URLs via the host file, but can I map a URL to a local html file on my hard drive without running a local server and loading the html file through there? Something like:

C:\myTestFile.html    www.google.com

I'd like to know how to do this on both Mac and Windows.

  • Actually, you're not mapping URLs at all. You're just resolving a hostname. – ckhan Feb 26 '13 at 15:49
  • What are you trying to do? Do you actually want to display a certain HTML page when attempting to access Google or do you just want to display a local HTML file in your browser? – Dennis Feb 26 '13 at 15:55
  • @ckhan thx. i'm not suprised that my vocab was off on this one – maxedison Feb 26 '13 at 16:15

No you cannot.

The hosts file is for mapping hostnames to IP addresses (and not "URLs"), expecially where a DNS server is not available, or where there's a need to override entries in a DNS server.

A file has no hostname/IP address, thus, what you're asking is not possible.

If you want to read more on this subject:

  • Thanks for both answering my question and helping clear up my vocab ;) – maxedison Feb 26 '13 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.