472,121 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 software developers and data experts.

Using ASP to capture a query string and redirect to SSL

I am looking for some method to capture, into a variable, the entire URL of
an http request and redirect to SSL. For example, if a user opens a browser
and typed in

http://myserver.com/application/some...893bdgt0248991

I want to be able to redirect to an SSL connection

httpS://myserver.com/application/som...893bdgt0248991

Your help is appreciated.
Jul 20 '06 #1
3 5621

Nuevo wrote:
I am looking for some method to capture, into a variable, the entire URL of
an http request and redirect to SSL. For example, if a user opens a browser
and typed in

http://myserver.com/application/some...893bdgt0248991

I want to be able to redirect to an SSL connection

httpS://myserver.com/application/som...893bdgt0248991

Your help is appreciated.
<%
url = "https://myserver.com/application/some.asp?"
qrystr = ""
For Each x In Request.QueryString
qrystr = qrystr & "&" & x & "=" & Request.QueryString(x)
Next

strRedirect = url & right(qrystr,len(qrystr)-1)

Response.Redirect strRedirect
%>

--
Mike Brind

Jul 20 '06 #2

"Nuevo" <im*********@gmail.comwrote in message
news:OG**************@TK2MSFTNGP02.phx.gbl...
>I am looking for some method to capture, into a variable, the entire URL of
an http request and redirect to SSL. For example, if a user opens a browser
and typed in

http://myserver.com/application/some...893bdgt0248991

I want to be able to redirect to an SSL connection

httpS://myserver.com/application/som...893bdgt0248991

Your help is appreciated.
This expression should get everything but the protocol from the original
URL, including the server's host name, file name and any directory info that
may have been included:

Url = Request.ServerVariables("SERVER_NAME") & _
Request.ServerVariables("URL") & "?" & _
Request.ServerVariables("QUERY_STRING")

Response.Redirect "https://" & Url
-Mark


Jul 21 '06 #3
On Thu, 20 Jul 2006 15:28:29 -0500, Mike Brind <pa*******@hotmail.com>
wrote:
<%
url = "https://myserver.com/application/some.asp?"
qrystr = ""
For Each x In Request.QueryString
qrystr = qrystr & "&" & x & "=" & Request.QueryString(x)
Next

strRedirect = url & right(qrystr,len(qrystr)-1)

Response.Redirect strRedirect
%>
You can actually use the QueryString collection as a scalar rather than
iterating through it:

<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<title>Default</title>
<p><%= Server.HtmlEncode(Request.QueryString) %></p>

--
Justin Piper
Bizco Technologies
http://www.bizco.com/
Jul 21 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by George | last post: by
11 posts views Thread by Alexander Bosch | last post: by
6 posts views Thread by Leonardo Santos-Macias | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.