3

I am attempting to redirect the IP address of my domain to the domain name and am running into trouble. The IP address does not redirect to the domain name listed in the redirect statement below.

The IP Address is http://184.168.27.44/

I've setup the following rule in my web.config file:

<rule name="IPHit" enabled="true" stopProcessing="false">
   <match url="(.*)" />
   <conditions>
      <add input="{HTTP_HOST}" pattern="^184\.168\.27\.44" />
   </conditions>
   <action type="Redirect" url="http://littlejawsbigsmiles.com/{R:1}" redirectType="Permanent" />
</rule>

The DNS is setup with the following records:

A (HOST) 
------------------------
@ --> 184.168.27.44

CNAME (Alias) 
------------------------
www --> @

Is there anything else that I'm mising? I'm not sure why this isnt working.

I have also tried the solutions provided here but the redirect still does not occur

3
  • Please be more specific about the actual problem than "running into trouble" Feb 21, 2014 at 18:14
  • @MathiasR.Jessen - The IP address does not forward to the domain name listed in the redirect statement. I'll update the question.
    – SwDevMan81
    Feb 21, 2014 at 18:15
  • @SwDevMan81 - it's not working because you're on a shared hosting plan. See details below.
    – kevinmicke
    Feb 26, 2014 at 21:13

3 Answers 3

5
+50

Your web.config rule is correct. The problem you're having is because you're on a shared hosting plan at Godaddy.com. Putting the IP in here returns:

Found 696 domains hosted on the same web server as 184.168.27.44

Since you're not the only site hosted on that IP, when a browser comes to the IP directly, the server doesn't know which site to return, so shows this error:

The page you tried to access does not exist on this server...

To be able to point to your site directly by IP, you would need dedicated hosting, which is much more expensive.

If you weren't on a shared IP, a more complete rule would look like this (tested on my own server which has a dedicated IP):

<rule name="IPHit" enabled="true" stopProcessing="false">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="184.168.27.44" />
    </conditions>
    <action type="Redirect" url="http://littlejawsbigsmiles.com/{R:1}" redirectType="Permanent" appendQueryString="true" />
</rule>

The above is similar to your and Vysakh's answers, but adds the appendQueryString property. That's necessary if you have any URLs with a query string (something after a "?"), so that the query string gets added during the redirect.

4
  • Perfect, thanks for the detailed answer @kevinmicke. This was very helpful.
    – SwDevMan81
    Feb 26, 2014 at 21:51
  • @SwDevMan81 - No prob...happy to help.
    – kevinmicke
    Feb 26, 2014 at 22:24
  • 1
    You need to create that rule in your web.config file. Am i correct?
    – luisdev
    Apr 17, 2018 at 13:18
  • 1
    @luisdev You're right—I updated the answer to confirm that. Thanks.
    – kevinmicke
    Jun 2, 2018 at 17:31
0

Try it with wildcard matching instead, there's no need to use regex matching when you only want to match one specific case without regard for the path. {R:0} will hold a back-reference to the url matched with * (anything after /):

<rule name="IPHit" enabled="true" patternSyntax="Wildcard" stopProcessing="false">
   <match url="*" />
   <conditions>
      <add input="{HTTP_HOST}" pattern="184.168.27.44" />
   </conditions>
   <action type="Redirect" url="http://littlejawsbigsmiles.com/{R:0}" redirectType="Permanent" />
</rule>
3
  • Thanks for the answer, I copied and pasted this in and then Recycle App Pool in the IIS management, but it still doesnt seem to work. I do have a rule to remove the existing rule if there is one <remove name="IPHit" />. Any other ideas?
    – SwDevMan81
    Feb 21, 2014 at 18:23
  • Is 184.168.27.44 the actual address on the interface or is there a NAT device in front of it? Feb 21, 2014 at 18:30
  • How could I tell? If I use something like http://www.getip.com/ it shows that as the IP address (this is hosted on godaddy).
    – SwDevMan81
    Feb 21, 2014 at 18:34
0

Try this:

<rule name="IP Hit" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="184.168.27.44" />
                </conditions>
                <action type="Redirect" url="http://littlejawsbigsmiles.com/{R:1}" redirectType="Permanent" />
</rule>

Explanation can be seen here...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .