I've read several threads on here about how to redirect an IP address to a domain. I'm currently setting up our development server inside the company network and thus we've set a "virtual" domain in the DNS of our main server.

So far all applications were installed running on {IP}:{Port}. Now I'd like to change that to the domain, since it's easier to use and read and because cookies differ for IP and domain respectively (thus preventing issues).

Obviously since I am running applications which require a specific port the redirects I've found do not work.

I tried the following settings in IIS Url Rewrite:

**Pattern:** {.\*}
**Condition:** {SERVER_NAME} matches **
**Action:** Redirect *Permanent* to `http://dev.myserver.de:{SERVER_PORT}/{R:1}`

But that does simply not work. My local browser just keeps using the IP based URL. I also tried using rewrite and other types of redirect. Why is this so?


Try using {HTTP_HOST} as the variable to match against instead of SERVER_NAME. The documentation suggests that SERVER_NAME will produce the canonical name of the box rather than what was in the host header of the request.

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.