Search code examples
web-applicationsweb-hosting

Host website on local machine using a fake domain name


I am trying to host a website with domain name but only on my machine (or accessible other machine on same network - optional). I don't want anyone else to access this website outside my home network. I want to use a fake domain name. For Ex: www.SampleWebsite.com - now when I type this website address on my machine it should open my application. But if I try this website from outside this should return not found (since this does not exist on internet). I know the basic hosting & I have hosted application on my local machine which is http://localhost/apps/TestApp/MyApplication address and is not accessible outside my laptop.

Is it just IIS setup? Do I need to setup something on my router? Does this required any special feature on router? Is there any third party tool (free) that can help me achieving this?

If above mentioned situation is possible then can I use existing domain for my application. Like facebook.com - and have my application running under that domain but this should not be accessible outside.


Solution

  • You don't need to do anything with your router. You would simply modify your hosts file, which is essentially a list of IP/hostname associations which any DNS lookup will check first.

    Instructions for locating and modifying your hosts file will vary depending on OS.

    Once you have edit access to your hosts file, find the entry for localhost and add an entry for whatever you want to be directed to your local system. E.g., on my system it looks like this:

    127.0.0.1 localhost www.whateverapp.com ...and so on...
    

    Now when I visit www.whateverapp.com I'm directed to my local machine.

    To answer the second part of your question, yes, you can use this to override any DNS lookup, even for real-world websites.