Forum Moderators: phranque

Message Too Old, No Replies

IIS URL Redirect (stop the insanity)

URL Rediction

         

The_Warden

4:46 pm on Dec 19, 2002 (gmt 0)

10+ Year Member



I've read endless messages posted on WebmasterWorld.com and haven't been able to find exactly my scenario. Apache is so much easier to deal with and stable but anyways... here's what I'm trying to do.

I want to redirect all traffic to my domain that uses HTTP. I want it to be redirected to HTTPS. How in the world can you do this using IIS?

Any direction would be greatly appreciated!

Dreamquick

5:28 pm on Dec 19, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd do it like this (mostly assuming that the HTTP and HTTPS sites are totally separate);

Method #1
Create an ASP page with a default name on the root of your HTTP site which contains the following;

<%
Response.Redirect "https://www.example.com/"
%>

Now use this document as your 404 page.

At this point any *regular* traffic (ie not traffic which would generate a 401, 403 or 50X status error) will be redirected to the root page of your HTTPS site. If they request the root page they are automatically redirected, or if they request a page name which doesn't exist they are redirected.

Obviously you could get really clever and transfer people to the right page on your HTTPS site too!

Method #2
The other way (I'm nervous about this one due to negative experiences with a web-based IIS control panel redirect);

Open the IIS manager and get to the properties dialog for your website, select the "Home Directory" tab. The dialog starts with three options, one of which is "a redirection to a URL"... need I say more?

This of course assumes that you are running the HTTPS site separately to your HTTP site as you only want to redirect for non-HTTPS traffic.

Method #3
If the sites aren't separate then I'd add something similar to #1 to one of your common scripting includes to check the following to determine if the request is HTTP or HTTPS based and redirect accordingly.

Request.ServerVariable("SERVER_PROTOCOL")

- Tony

The_Warden

7:37 pm on Dec 19, 2002 (gmt 0)

10+ Year Member



Thanks for the reply.

I guess I should have gave a more detailed setup information. IIS is running on a Windows 2000 Server and IIS is running with PHP 4.x. So I'm not using ASP and no the site is not being run separately. I just want to redirect any traffic that may go to HTTP to HTTPS. I do this easily with Apache, just can't seem to figure out how with IIS.

I guess maybe I should be looking into getting PHP to redirect the traffic? Just doesn't make sense to me to have the Server Side Scripting language to do this when the web server it self should be handling it.

Thanks!