Solved

Redirect IIS7 Site to force www

Posted on 2011-03-09
2
1,017 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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