Page 2 of 2

Re: Looking for Simple, Elegant way to keep HTTPS and HTTP urls straight

Posted: Mon Sep 07, 2009 3:30 pm
by Jeff
irish wrote: Here is what I do:

I create two UDT

NonSSL

Code: Select all

if ($_SERVER['SERVER_PORT']==443)
{
$url = "http://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
}
ssl

Code: Select all

if ($_SERVER['SERVER_PORT']!=443)
{
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
}
Then create two templates. Both are identical except one will have the {NonSSL} where the other will have {ssl} Then I assign the appropriate template to the pages as needed.

I'm sure there is an faster, more efficient way, but this one works well for me.

Can't wait for 1.7 if it has a simple checkbox for this.
Could this be insert at the page smarty level (the box for smarty logic on the options tab)? Instead of in the template.