Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

But stuck on this one, looked on google but couldnt find anything.

The deployment of the site went slightly wrong and some pages were being saved as:


Where the IP was the underlying IP address for the domain (so the pages served fine).

Now however, lots of crawlers are indexing the IP site, AND the main site. This is a waste of bandwidth and causes some duplicate content issues!

How can I redirect the IP to the domain?

share|improve this question
up vote 6 down vote accepted

When site is accessed by IP the HTTP_HOST will be an IP address (or maybe just blank -- I have tested this on my PC and is was an IP address). If so -- then you can use simple URL Rewrite rule to do a 301 redirect to a proper domain name.

Here is an example of such web.config (when HTTP_HOST is an IP). You need URL Rewrite module to be installed (v1 is already bundled with IIS 7.5, but you may want to upgrade to v2). Works fine locally on Windows 7:

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="IP Hit" stopProcessing="true">
                    <match url="(.*)" />
                        <add input="{HTTP_HOST}" pattern="" />
                    <action type="Redirect" url="{R:1}" redirectType="Permanent" />

P.S. You would need to change my local IP address to the one you have got on server (73.34.12...)

share|improve this answer
Super! Exactly what I was after thanks! – Tom Gullen Jul 1 '11 at 22:38
@LazyOne This works perfectly. Does it matter if the browser sends the IP address or a blank entry in the request header? I've read that some browsers send the IP others just a blank entry. – Jacques Jun 30 at 13:42
@Jacques Well ... the rewrite rule I have provided in my answer works for IP. You may create similar but for empty value. But in general -- my local tests show that the browsers that I have used send IP in that field. – LazyOne Jun 30 at 19:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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