I have an e-commerce site and I want to enable https only in the e-commerce section of the site located at https://mysite.com/buy
Since all links on my pages are relative, when someone visits http://mysite.com and clicks the Buy button, they are redirected to http://mysite.com/buy
In addition, if they visit https://mysite.com/buy and click on a link to another page, they are translated to https://mysite.com .
The reason I want https only in this section is because I have external elements (e.g. Google Maps, Youtube, Twitter, etc.) that cannot be sent via https.
Is there a way with htaccess that I can force / directory directories to force https, but every other page forces http?
Edit: In case anyone is interested, I was able to solve this using PHP. I would prefer the htaccess solution, but now this will work:
if($_SERVER['HTTPS'] == "on") { if(strpos($_SERVER['REQUEST_URI'],"buy") === false) { Header("Location: http://$_SERVER['HTTP_HOST']."".$_SERVER['REQUEST_URI']"); } }
source share