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>
janessaallenAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Brad HoweConnect With a Mentor DevOps ManagerCommented:
DNS can be fine  but is it setup in IIS as a binding.?

1) Disable ALL URL Rewrite temporarily.
2) Open IIS, Select your Site and click Bindings.... in the Action Pane.
3) Add 2 bindings to your "Web Site"
   1. Go to IIS Manager
   2. Select your “Web Site” on the left pane.
   3. In the "Actions" pane on right hand side, click on "Bindings..."
   4. Click ADD.
     * You should have 2 or more bindings depending on your urls. These you will now change to bind to your
        domain name.
        a) Type (http) - host Name (alternativesforseniors.com) -  Port (80) - IP address (All Unassigned)
        b) Type (http) - host Name (www.alternativesforseniors.com) -  Port (80) - IP address (All Unassigned)

OR
        a) Type (http) - host Name () -  Port (80) - IP address (All Unassigned)

The DNS may work but IIS may not be setup properly.

You could also by pass DNS entirely and use a hostfile entry to test only.

Let me know,
Hades666




0
 
Brad HoweDevOps ManagerCommented:
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
0
 
janessaallenAuthor Commented:
Thanks. It still doesn't work when I type: http://alternativesforseniors.com/ ???

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Brad HoweDevOps ManagerCommented:
Do you have the binding configured the for the site?

Does nslookup resolve that url?

Cheers,
Hades666
0
 
janessaallenAuthor Commented:
I should have it configured.  I just did an nslookup on alternativesforseniors.com (w/o the www) and it worked.
0
 
janessaallenAuthor Commented:
I will double check all the bindings tonight and let you know. Thanks so much.
0
 
janessaallenAuthor Commented:
you're awesome!  it works now.  thank you SO much.
0
 
Brad HoweDevOps ManagerCommented:
Glad I could help. Diagnosing is tough when we are picking at possible configuration issues.

Have a good one.

Hades666
0
All Courses

From novice to tech pro — start learning today.