HTTPS login only from frontside

Re: [ht1080z] HTTPS login only from frontside

By gregThomas - September 17, 2012

Hi Karls,

The best way to force a user to log-in securely is to place the following PHP code at the top of your log-in page, or any page you want the user to be able to only visit using https:

if (preg_match('/^http:/i', thisPageUrl())) { redirectBrowserToURL(preg_replace('/^http:/i', 'https:', thisPageUrl())); }
This will force the page to redirect to HTTPS. I would also recommend changing any links to the page from http:// to https://, but this is not essential as the php code above will force the change anyway.


Greg Thomas

PHP Programmer -

Re: [greg] HTTPS login only from frontside

By ht1080z - September 17, 2012

Thank you Greg, it worked just you said.