Hi - I am still struggling can not make a server side redirect happen
from https to http.
its not the generation of the URL that is the problem; it just simply
seems to ignore the fact that I am redirecting from secure to a plain
http page (the other way round always work). The user can click on http
links and follow but redirects or AddHeader always stays within https.
After reading
http://www.4guysfromrolla.com/aspfaq...Q.asp?FAQID=72 (ADPFAQs.com)
and
http://www.somacon.com/p145.php (Permanent Redirect with HTTP 301)
Here is my final code (using AddHeader instead of Redirect) - I also
made sure not have ANY output before I call the page. However, some
session variables are written (these are needed to identify the user
once he is logged on) - Buffering is turned on as per standard.
Function redirectNoSSL(sUrl)
Dim sNewURL
sNewURL = stripSSL(sUrl)
If Response.Buffer=True then
Response.Clear
Response.Buffer=False
End If
'Call Response.Redirect(sNewURL)
' instead of redirect!
Response.Status = "301 Moved Permanently"
Call Response.AddHeader ("Location", sNewURL)
End Function
(stripSSL works fine, and is supposed to with relative URLs; it just
recreates the current URL with http: instead of https, and appends the
(relative) target URL, see code below)
any other suggestions.
Axel
' example: Redirect stripSSL("../../images/head.gif")
Function stripSSL(sTarget)
Dim host, sUrl, i
stripSSL=""
if sTarget="" Then Exit Function
sUrl=Request.ServerVariables("URL")
host=Request.ServerVariables("server_name")
i=InStrRev(sUrl, "/")
stripSSL= "http://" & host & Left(sUrl,i) & sTarget
End Function
Adrienne Boswell wrote:
> Gazing into my crystal ball I observed Axel <> writing in
> news:uHRJEE$:
>
>> Hi
>>
>> I am trying to redirect from some (login) pages from https to http by
>> using >>Response.Redirect<< but it seems to always end up on https
> pages
>> anyway. The only way I get the users back to http is by them clicking
> on
>> my (explicit) links but I want to drop them back to http as soon as
> they
>> are logged in.
>>
>> The other way around (http to https) works fine. What could cause such
> a
>> behavior? Maybe some global switch in global.asa? Or cookies set by
> the
>> secure page? Its really weird.
>>
>> I am considering doing the redirect client side but I don't want the
>> whole page to load and then to the redirect as its slooow. OTOH I am
>> scared of cutting the page short server site in case the client
> redirect
>> method fails (e.g. due to ignoring javascript or meta headers). Is
> there
>> a sure fire way to redirect to non-secure after successful login?
>>
>> thanks in advance
>> Axel
>>
>
> Here's what I do:
>
> serverswitchon = "https://" & request.servervariables("SERVER_NAME")
> serverswitchon = serverswitchon & left(request.servervariables
> ("PATH_INFO"),instrrev(request.servervariables("PA TH_INFO"),"/"))
> serverswitchoff = "http://" & request.servervariables("SERVER_NAME")
> serverswitchoff = serverswitchoff & left(request.servervariables
> ("PATH_INFO"),instrrev(request.servervariables("PA TH_INFO"),"/"))
>
> response.redirect serverswitchoff & "pagename.asp" 'to http
> response.redirect serverswitchon & "pagename.asp" 'to https
>