Link to home
Start Free TrialLog in
Avatar of Justin Smith
Justin SmithFlag for United States of America

asked on

Redirect to HTTPS and maintain URL

What is the easiest way to redirect a URL to https:// ?  I need to make sure that the rest of the URL is maintained.  This is a sharepoint (wss 3) site running in IIS 6.  
Avatar of shadowlesss
shadowlesss
Flag of United States of America image

Avatar of Justin Smith

ASKER

I need to maintain the URL they type in (just add https instead of http).....so I can't necessarily redirect every request to one static URL.
IIS 7.0 found on Windows Server 2008 has this a rewrite module that can be coded to do this sort of thing.  If you need to do this with IIS 6.0 then you will need to consider some 3rd party solutions as this functionality is not native to IIS 6 or lower version
Surely there is an ASP script or something to do this???
ACH1LLES,
For SharePoint to properly support the use of HTTPs (and I'm assuming your SharePoint Web application right now is not using HTTP, thus your request), you need to implement an Alternate Access Mapping (AAM).
The high level steps are this:
1. Extend the Web application (in Central Admin) your site site is in now to use another URL - in the 'extend web application' dialog, you'll get prompted for the URL and port (443) and the option to use SSL
2. Perform an IISRESET so that your new extended web application appears in IIS
3. Then go into IIS and bind your SSL certificate to that new extended web application (I'm assuming you already have an SSL certificate or are planning to get one)
4. Advise your users that the URL exists, perform whatever redirect, etc. so you have a properly supported SharePoint site on the port/URL necessary
Reference link if you want the nitty gritty: http://technet.microsoft.com/en-us/library/cc288609.aspx
A great series from the SharePoint Team - http://blogs.msdn.com/sharepoint/archive/2007/03/06/what-every-sharepoint-administrator-needs-to-know-about-alternate-access-mappings-part-1.aspx
Groove,

It's already working on 443......if they try to access on 80 I want them to be redirected to 443 (instead of getting the 403.4 error).  This would be an easy task if I wanted 80 and 443 to be available (by using AAM's), but I don't want 80 at all, I want 80 to redirect to 443.  
Ah, sorry, I see.
Here's a screenshot regarding what you'd want to do on your HTTP site (not the HTTPS site), in IIS. I'm assuming you are on Windows Server 2003, but you'd be looking for similar functionality on Windows Server 2008.

IISRedirect.png
In the above screen, put https://www.portalsomewhere.com$S$Q in the Redirect to:. This will keep the page they are on but forward them to the new URL. You may (or may not) want to make this a Permanent Recirect also.
Thanks for the responses.  Yeah I know I can do it this way, by making a seperate IIS site and redirecting.  I was thinking there was a way to make a custom 403.4 page to do the redirection so I wouldn't need to create the additional IIS site.  I can make a custom page to do the redirection, but I need to know how to do it and also keep the original URL in tact.
RQC,

I will try this (but would prefer a custom 403.4 error page :) )
Yes, you can also do it by reading the server variables URL and QUERY_STRING and building the Redirect. Classic ASP would be like this:
RedirectURL = "www.whatever.com" & Server.Variables("URL")
 
If Len(Server.Variables("QUERY_STRING")) > 0 then
    RedirectURL = RedirectURL & "?" & Server.Variables("QUERY_STRING")
End If
 
Response.Redirect RedirectURL

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Justin Smith
Justin Smith
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial