Solved

Redirect IIS7 Site to force www

Posted on 2011-03-09
2
1,015 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

815 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

6 Experts available now in Live!

Get 1:1 Help Now