http and https

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JeremyBASS

http and https

Post by JeremyBASS »

Hi... just drop this in the top of any file and it will redirect you from http to https with out much bother... anything better is welcome... improvment is goood  ;D

Code: Select all

if ($_SERVER['SERVER_PORT']!=443)
{
$url = "https://". $_SERVER['SERVER_NAME'] . ":443".$_SERVER['REQUEST_URI'];
header("Location: $url");
}
scanreg
Forum Members
Forum Members
Posts: 19
Joined: Sun Nov 04, 2007 2:24 pm

Re: http and https

Post by scanreg »

Hi

Tried putting the code into the top of the Minimal template but the page rendered weird and there was no SSL. Here's the full code:

Minimal SSL

Code: Select all

{process_pagedata}
if ($_SERVER['SERVER_PORT']!=443)
{
$url = "https://". $_SERVER['SERVER_NAME'] . ":443".$_SERVER['REQUEST_URI'];
header("Location: $url");
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<__html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{* Change lang="en" to the language of your site *}

<head>

<title>{sitename} - {title}</title>
{* The sitename is changed in Site Admin/Global settings. {title} is the name of each page *}

{metadata}
{* Don't remove this! Metadata is entered in Site Admin/Global settings. *}

{stylesheet}
{* This is how all the stylesheets attached to this template are linked to *}

</head>

</__body>

      {* Start Navigation *}
      <div style="float: left; width: 25%;">
         {menu template='minimal_menu.tpl'}
      </div>
      {* End Navigation *}

      {* Start Content *}
      <div>
         <h2>{title}</h2>
         {content} 
      </div>
      {* End Content *}

<__body>
</__html>
Have I put it in the wrong place?

Any ideas most welcome, thanks  :)
JeremyBASS

Re: http and https

Post by JeremyBASS »

Yep in's in the wrong stop... you put in a file... ie: the index file, login (in the admin) etc.

Now you could I put it in A UDT to have only one page go to HTTPS... but then you need another one to reverse back to HTTP in the rest. 

Really it is what you want that determines what you do with it...

hope this helps

jeremyBass
scanreg
Forum Members
Forum Members
Posts: 19
Joined: Sun Nov 04, 2007 2:24 pm

Re: http and https

Post by scanreg »

So, it needs to go into a static file, not any dynamic content that CMS creates, is that about right?

Would be great if you could content as SSL only
Last edited by scanreg on Sun Feb 15, 2009 2:54 pm, edited 1 time in total.
JeremyBASS

Re: http and https

Post by JeremyBASS »

Well no.. under Extensions in User Defined Tags you can add this, which you can call dynamicly, for any page you wish.  hope that makes better sense.

cheers
jeremyBass
scanreg
Forum Members
Forum Members
Posts: 19
Joined: Sun Nov 04, 2007 2:24 pm

Re: http and https

Post by scanreg »

I see, add it into the User Defined Tags and then add it to the top of the template by calling it by its name:

{ssl}

It worked, thanks  :)
Post Reply

Return to “Tips and Tricks”