Host website on local machine using a fake domain name
Asked Answered
R

2

7

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.

Regalado answered 29/7, 2017 at 17:12 Comment(0)
S
11

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.

Scissure answered 29/7, 2017 at 17:21 Comment(5)
Thanks for instant reply. But I am not able to override re world website. I tried it with facebook but this message was displayed - This site can’t be reached. www.facebook.com refused to connect. Does that require something different?Regalado
One more thing, I am not able to include folder path with domain name. I tried - 127.0.0.1/apps/MyWebsite/MyApplication/ www.SampleSite.com but this is not working. Any suggestion?Regalado
I think you should probably do some reading around the subject of host names and web technologies in general. Your hosts file shouldn't contain anything except IP addresses and host names. The application path you've given here looks like a local path to where your application lives. It does not belong in your hosts file.Scissure
Start your application normally using IIS (or however else you do it). Now access it using 127.0.0.1 to prove you can get to it. Now if your hosts file is set up correctly, you should be able to access exactly the same application via www.samplesite.com.Scissure
PS if you had www.facebook.com in your hosts file pointing to 127.0.0.1, then you would need a local web app responding on port 80 in order to actually see anything when you try to access it.Scissure
R
4

If you are on windows try adding somthing like this to your hosts file ( c:/windows/system32/drivers/etc/hosts ).

Local-IP - - Domainname

127.0.0.1 TestTest.com

Let us know if it helped.

Reward answered 29/7, 2017 at 17:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.