Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

forcing HTTPS on a page

Status
Not open for further replies.

EdwardMartinIII

Technical User
Sep 17, 2002
1,655
0
0
US
Is there a way to force a page to be viewed under HTTPS?

I'm hosting a site on Apache, via Dreamhost.com

All the LINKS to the page are HTTPS, but this is just in case some User gets the strange notion to manually type " to go to the page.

I suppose there could be a client-side JS way of doing it, but a really DETERMINED User could probably work around that, huh?

Thanks!


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
You can use .htacces and rewrite rules to always re-direct any not secure connections to the secure page. Here is a linkwith some examples.

 
Oh.

Man, could it be THAT simple?

I could simply add a line to my .htaccess file like:

Code:
Redirect permanent [URL unfurl="true"]http://www.banana.com/minx.html[/URL] [URL unfurl="true"]https://www.banana.com/minx.html[/URL]


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
For some reason I thought redirects wouldn't work on full URLs.

[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
For me I added a line in my httpd.conf file in the VirtualHost section for port 80. This is the line I added:
Code:
RedirectMatch ^/(.*) [URL unfurl="true"]https://myserver.domain.com/$1[/URL]

This way it will work for ALL resources on the server.

Einstein47 (Starbase47.com)
“PI is like love - simple, natural, irrational, endless, and very important“
 
Hm... I only want it to apply to a single page or reduced set of pages, not all the resources.


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Is there a way of doing this for a single page?

(or set of individual pages?)


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Okay, this is what did it:

Code:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^FileName.html$ [URL unfurl="true"]https://www.TargetDomain.com/FileName.html[/URL]

Enjoy!


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Argh, another domain's giving me grief in the exact same way.

I have
When I go to I want the site to switch over to HTTPS.

But ONLY when I go into that subdirectory.

In my top-level .htaccess file, I've tried:

Code:
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/shop$ [URL unfurl="true"]https://www.mydomain.com/shop[/URL]
and
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ([URL unfurl="true"]http://www.mydomain.com/shop/.*)[/URL] [URL unfurl="true"]https://www.mydomain.com/shop/[/URL]
and
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (/shop/.*) [URL unfurl="true"]https://www.mydomain.com/shop/[/URL]

but none of these do the trick. None of them, when you manually enter , immediately snaps you into
Can someone suggest what I'm doing wrong, or better yet how to fix it?

Thanks!


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
In case it helps, the .../shop directory goes to a Zen Cart installation.


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Ha! Solved it. I found the settings in Zen Cart that told it, basically, "Okay, you can open your transaction pages under HTTPS."

I KNEW it was had to be a setting somewhere in Zen Cart...


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Glad you found the config setting - sorry I wasn't more help.

Einstein47 (Starbase47.com)
“PI is like love - simple, natural, irrational, endless, and very important“
 
Nah, don't fret -- you guys got me started thinking in the right direction. It's good, it's good.

Besides, I had two different-but-slightly-related issues in one thread -- my bad if I caused confusion.

Cheers,


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top