Solved

Redirect IIS7 Site to force www

Posted on 2011-03-09
2
1,014 Views
Last Modified: 2012-05-11
I have a site I am trying to get up and running.  I am trying to actually force 2 things.  I am trying to force the entire site to be ssl since I have a certificate for www.securesite.com. I can do that, but when someone types http:// they get an error.  If someone also types it without the www they get an error.  I need to redirect all requests to https://www.  Any ideas how I can do this so when I set it to require ssl the page always comes up.

Oh Yeah it is an ASP.net page so an .htaccess is not going to work (or will it).  This is also running on a server with multiple sites, so the default web site is not live.
0
Comment
Question by:mrwarejr
2 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 35090593
Hi,

You can use the URL rewrite feature.

Install URL Rewrite Module
x86 - http://go.microsoft.com/?linkid=9722533
x64 - http://go.microsoft.com/?linkid=9722532

Create bindings & Assign Certificate to website
Add 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 (yourdomain.com) -  Port (80) - IP address (*)
        b) Type (http) - host Name (www.yourdomain.com) -  Port (80) - IP address (*)
        c) Type (https) - host Name ( ) -  Port (443) - IP address (*)

Test your sites that they all load
1. http://domain.com
2. http://www.domain.com
3. https://domain.com
4. https://www.domain.com

* if some URLS don't load then you have a DNS issue. You can use "nslookup" from CMD to troubleshot these.
   eg: nslookup domain.com  
           - should resolve the WAN IP.

Create URL Rewrite
1.Open the web.config file for you website.
2.Under the /configuration/system.webServer, add the following section and then save the file.

eg: If this is the first rule the <rewrite> tags are needed too.

<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://www.yourdomain.com/{R:1}" />
</rule>
</rules>
</rewrite>

* You can also see URLREWRITE in the IIS Administrator Console under the Features Tab.

If you want help creating import masks, please provide a list of all the sample URLS and there supposed redirects and we would be glad to help create an import_rules file for you.

Here is a great article on how to create 301 redirect rules.
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/
 
Let me know if you have issues.
Cheers,
Hades666    
0
 

Author Closing Comment

by:mrwarejr
ID: 35095323
Appreciate the help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now