Reply to topic
Most Wanted ASP and ASP .Net Scripts
Jitu
HostMySite Tier2 Tech

Joined: 02 Mar 2004
Posts: 8
Reply with quote
Please feel free to post commonly used scripting questiosn and solutions here.

Right now we are looking for an asp redirect script that would redirect the a user from a nonsecure link to a secure link for certain pages.

For example when some one goes to
http://www.domain.com/login.asp
they are redirected to https://www.secureurl.com/domain/login.asp

Please post any sample script that might help us achieve that. Thanks.
cpnet


Joined: 03 Nov 2004
Posts: 135
Reply with quote
The following code works for me...

Code:
<html>
<%
   'This script should go right after the <HTML> opening tag
   
   'Don't send response text as we go, in case we do a redirect
   Response.Buffer = True
   
   'The base URL of our secure server   
   SecSrv = "https://www.secureurl.com/domain"   
   
   'Check if HTTPS is turned on.  If not, redirect to the secure site
   If (UCASE(Request.ServerVariables("HTTPS")) <> "ON") Then
      Response.Clear
      Response.Redirect( SecSrv & Request.ServerVariables("PATH_INFO"))
   End if
%>

...

</html>
Thats Good but this might save space in code
mdegeofroy


Joined: 20 Jul 2005
Posts: 6
Location: Egypt
Reply with quote
place at top of script <!--#include file="ForceSSL.inc" --> in page to protect

make text file with code (same code as before)

<%
Response.Buffer = True
SecSrv = "https://www.secureurl.com/domain"
If (UCASE(Request.ServerVariables("HTTPS")) <> "ON") Then
Response.Clear
Response.Redirect( SecSrv & Request.ServerVariables("PATH_INFO"))
End if
%>

save it in same directory as file to protect and name it - ForceSSL.inc

now you can add one line in all pages to protect

I am not a pro so try it do not take my word for it but it works for me:)
Correction
mdegeofroy


Joined: 20 Jul 2005
Posts: 6
Location: Egypt
Reply with quote
Not .inc (no security ) .asp (cannot be browsed)

place at top of script <!--#include file="ForceSSL.asp" --> in page to protect

make text file with code (same code as before)

<%
Response.Buffer = True
SecSrv = "https://www.secureurl.com/domain"
If (UCASE(Request.ServerVariables("HTTPS")) <> "ON") Then
Response.Clear
Response.Redirect( SecSrv & Request.ServerVariables("PATH_INFO"))
End if
%>
Most Wanted ASP and ASP .Net Scripts
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic