Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Redirect IIS7 Site to force www

Posted on 2011-03-09
2
Medium Priority
?
1,030 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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