Solved

Redirect IIS7 Site to force www

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
Imagine a situation that you have installed SSL (http://en.wikipedia.org/wiki/Secure_Sockets_Layer) Certificate on your Cisco ASA (Cisco Adaptive Security Appliance) firewall. Installation of SSL certificate on ASA is an another topic for which you …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

13 Experts available now in Live!

Get 1:1 Help Now