-2

I am wanting to serve a single webpage from my IP for a particular host/domain within Windows. Is this even possible? Any ideas how to achieve this?

Is it possible to have something like this in "hosts" file?

203.223.22.22 microsoft.com
192.168.1.1   microsoft.com/something/index.php

If not, is there another solution to allow me to serve up just that page while normal traffic continues on to the other IP?

TheCleaner
  • 32,352
  • 26
  • 126
  • 188
BlueDotRo
  • 33
  • 3
  • 2
    The host (microsoft.com) will be translated to 192.168.1.1 an then therse is looked for the content under /something/index.php. So you can't solve it using a hostfile. Maybe some http proxys can manage this. – marsh-wiggle Dec 03 '14 at 11:49
  • 3
    I'm going against the normal grain here and saying that the question shouldn't be closed. The question is very basic for a Windows admin in its original form asking about the `hosts` file, but sysadmins come in all flavors (I prefer strawberry), and the underlying question about url redirection is really the key question here. I'll edit the question in hopes that the "season of kindness" prevails. – TheCleaner Dec 03 '14 at 16:47

1 Answers1

5

No, it's not possible with the /etc/hosts file. You can only map IP addresses to host names.

One option to achieve that would be to set up a reverse proxy and configure it to answer everything from the remote server except a certain URL.

What is your goal with this?

Sven
  • 97,248
  • 13
  • 177
  • 225
  • but do you know a work-around for this? – BlueDotRo Dec 03 '14 at 11:47
  • 1
    Yes, I even outlined it in my answer. And again: What is your end goal? What problem do you try to solve? – Sven Dec 03 '14 at 11:50
  • I need to test an authentication method to see if can be hacked using your own files. – BlueDotRo Dec 03 '14 at 11:52
  • 6
    @BlueDotRo If you're tasked with "testing a hack" and you don't know how host files work, you might want to reassign the job. – Reaces Dec 03 '14 at 13:31
  • @Reaces Making strange assumptions and trying funny things is not the worst way to learn. – marsh-wiggle Dec 03 '14 at 14:02
  • @boboes I don't see how any of that is relevant here. No-one said anything about learning, or trying new things. This is a person doing a job, and getting fundamentals wrong. – Reaces Dec 03 '14 at 14:31
  • 1
    @Reaces in my country I have to be multi-functional/multi-tasking and instead of being smart, you should understand that not everybody are on the same wave with you and sometimes they dont use the right words. Anyway, with the help of Boboes I found a bug that my senior developer said to be "It can't be". So . as PM in my country I have to be a developer, architect, QA, etc and yes... I want to quit the job for a better one :) And thanks to all that help me and gave me negative feedback. – BlueDotRo Dec 03 '14 at 15:35
  • 1
    @BlueDotRo Would you rather we all pretend half measures are OK, because you're only the person executing them, not the one assigning them? A bad situation is a bad situation regardless of blame. Negative feedback on a negative situation is a good thing... – Reaces Dec 03 '14 at 16:32