Force HTTPS

J

John McDermidt

Is there a way to use HTTPS only on certain pages? I have two pages that I
want to use my SSL Cert, but the rest of the files I do not... they are all
in the same folder, and I can not move them.
 
R

Ray at

You could add something like this to the top of your pages:

<%

If UCase(Request.ServerVariables("HTTPS")) = "OFF" Then
'''get page
sRedirect = "https://" & Request.ServerVariables("SERVER_NAME") &
Request.ServerVariables("PATH_INFO") & "?" & Request.Querystring
Response.Redirect sRedirect
End If

%>

Ray at work
 
A

Andrew Durstewitz

Neat. I never knew you could do it with ASP. I just allways did it
with the server configuration.

-Andrew

* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.
 
S

Splatter

Individual items have a security tab as well. Right click the page inside
the IIS snap in & go to properties. Click the security tab, edit the cert,
and check off the only allow ssl connections. The individual settings
override the global ones.

HTH

DP
 
J

John Cesta

Is there a way to use HTTPS only on certain pages? I have two pages that I
want to use my SSL Cert, but the rest of the files I do not... they are all
in the same folder, and I can not move them.

Yes, set the entire folder to SSL and just use https on the two pages.
Or, just set each page to SSL in the MMC. If you are on a shared
hosting environment have your hosting company do this for you.

John Cesta

http://www.cybersmarts.net[/QUOTE]
 
M

Michael D. Ober

I didn't know you could do it via individual page properties. The method I
use is:

<%
dim myname
dim i

myname = Request.ServerVariables("SCRIPT_NAME")
i = instr(myname, ">")
if i > 0 then myname = left(myname, i-1)
do while left(myname,1) = "/"
myname = mid(myname, 2)
loop

if ucase(Request.ServerVariables("HTTPS")) = "OFF" then
response.redirect https://<siteurl>/ & myname
end if
%>

The <siteurl> is the base of the current page.

By putting this code before any HTML code on the ASP page, the ASP page will
only show with SSL. If the user cancels the certificate or security switch,
the previous page will remain the current page.

Mike Ober.
 
S

Splatter

Michael D. Ober said:
I didn't know you could do it via individual page properties. The method I
use is:
By putting this code before any HTML code on the ASP page, the ASP page will
only show with SSL. If the user cancels the certificate or security switch,
the previous page will remain the current page.

Mike Ober.

Thanks Mike I'll remember that. Yes they do, which is handy with non
WebPages as well. I have a zip file I wanted to host to everyone not just
my users via ssl and I was able to override the sight security on that file
so it can be served anonymously.

DP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top