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

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

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

Post 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.
Post Reply

Return to “Developers Discussion”