EllisLab text mark
Advanced Search
     
Enabling SSL on *some* pages of EE2 site
Posted: 28 June 2011 09:12 AM   [ Ignore ]
Joined: 2011-03-02
19 posts

HI all,

Is it possible to enable SSL on certain pages of an EE2 site? I know that you can redirect to a different directory, but I am actually talking about certain pages within a EE site structure.

For example:

/home
/about
/my-account [SSL enabled]
/my-basket [SSL enabled]
/checkout [SSL enabled]

I have found plenty of .htaccess examples of how to redirect to a different location on the server, and this is fine if my site were not EE driven, but how does this help with EE, as all content is displayed in one location (using the index.php file)? Do I have tocopy the entire site to the https folder on my server?

Thanks for your time,

Ben

 
Posted: 09 August 2011 08:57 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2010-09-17
442 posts

I am also wondering same thing.  I am using this PHP code and adding to top of template currently in a snippet.  Make sure and allow PHP outgoing.  This does work, but I am wondering if this is good code to use or is there a better way?  HTACCESS does not work as using IIS. Can anyone advice?

<?php
if ($_SERVER['SERVER_PORT']!=443)
{
$url 
"https://"$_SERVER['SERVER_NAME'":443".$_SERVER['REQUEST_URI'];
header("Location: $url");
}
?> 
 
Posted: 09 August 2011 09:09 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-15
426 posts

Try this: http://dmlogic.com/add-ons/forcessl/

 Signature 

ExpressionEngine Development | 21purple Web Studios, LLC or on Twitter @th3mus1cman

 
Posted: 09 August 2011 09:25 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2010-09-17
442 posts

Is this a safer method or more reliable than the PHP redirect I mentioned? I am using Structure as well if that matters.

 
Posted: 10 August 2011 12:08 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2010-09-17
442 posts

I tried that add-on and it did not work.  This seems to be best option I have seen so far.  I put in a snippet and call it before anything else in template. Just had to enable PHP Input parsing.

<?php
if ($_SERVER['SERVER_PORT'!= 443{   
header
("HTTP/1.1 301 Moved Permanently");   
header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);   
exit();
}
?> 
 
Posted: 10 August 2011 11:05 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2010-09-17
442 posts

In case anyone is wondering, IIS URL Rewrite module will not work to redirect a page or folder to another destination with EE.  The reason is that URL ReWrite needs a physical directory or file and EE uses index.php for everything.  Dm Force SSL add on did not work with EE 2.2.1, so the only method we can find that works is posted above.

 
Posted: 06 August 2012 09:39 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-06-14
34 posts

I’m not sure what I am doing wrong but I copied and pasted the code into a global template then called it with PHP enabled and input parsing and it doesn’t redirect for me…