Link to home
Start Free TrialLog in
Avatar of janessaallen
janessaallenFlag for United States of America

asked on

Canonical Redirect in IIS 7.0 Web Config

I cannot figure out why the following is still giving me a 404!! Anyone?  I must fix this asap.

<rule name="Enforce canonical hostname" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" negate="true" pattern="^alternativesforseniors\.com$" />
    </conditions>
    <action type="Redirect" url="http://www.alternativesforseniors.com/{R:1}" redirectType="Permanent" />
  </rule>
Avatar of Brad Howe
Brad Howe
Flag of Canada image

Hi,

Use this as your template.

<rewrite>
        <rules>
   <rule name="CanonicalHostName - Force WWW on domain url">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www\.alternativesforseniors\.com$" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://www.alternativesforseniors.com/{R:1}" />
    </rule>
       </rules>
</rewrite>

This means MATCH all incoming URLS. Check for the HTTP_HOST. IF the HTTP_HOST doesn't equal (negate=true) www.alternativesforseniors.com the redirect to www.alternativesforseniors.com. The {R:1} in the redirect is the URI attached to the oringinal request.

Cheers,
Hades666
Avatar of janessaallen

ASKER

Thanks. It still doesn't work when I type: http://alternativesforseniors.com/ ???

Do you have the binding configured the for the site?

Does nslookup resolve that url?

Cheers,
Hades666
I should have it configured.  I just did an nslookup on alternativesforseniors.com (w/o the www) and it worked.
ASKER CERTIFIED SOLUTION
Avatar of Brad Howe
Brad Howe
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will double check all the bindings tonight and let you know. Thanks so much.
you're awesome!  it works now.  thank you SO much.
Glad I could help. Diagnosing is tough when we are picking at possible configuration issues.

Have a good one.

Hades666