Solved

Canonical Redirect in IIS 7.0 Web Config

Posted on 2011-02-13
8
933 Views
Last Modified: 2012-06-21
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>
0
Comment
Question by:janessaallen
  • 4
  • 4
8 Comments
 
LVL 30

Expert Comment

by:Brad Howe
ID: 34887502
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
 

Author Comment

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

0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 34887963
Do you have the binding configured the for the site?

Does nslookup resolve that url?

Cheers,
Hades666
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:janessaallen
ID: 34889603
I should have it configured.  I just did an nslookup on alternativesforseniors.com (w/o the www) and it worked.
0
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 34890801
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
 

Author Comment

by:janessaallen
ID: 34891254
I will double check all the bindings tonight and let you know. Thanks so much.
0
 

Author Comment

by:janessaallen
ID: 34892924
you're awesome!  it works now.  thank you SO much.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 34893060
Glad I could help. Diagnosing is tough when we are picking at possible configuration issues.

Have a good one.

Hades666
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question