ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Enabling SSL on *some* pages of EE2 site

June 28, 2011 9:12am

Subscribe [4]
  • #1 / Jun 28, 2011 9:12am

    Pagemakers

    11 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

  • #2 / Aug 09, 2011 8:57pm

    bgarrant

    356 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");
    }
    ?>
  • #3 / Aug 09, 2011 9:09pm

    the3mus1can

    426 posts

  • #4 / Aug 09, 2011 9:25pm

    bgarrant

    356 posts

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

  • #5 / Aug 10, 2011 12:08am

    bgarrant

    356 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();
    }
    ?>
  • #6 / Aug 10, 2011 11:05am

    bgarrant

    356 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.

  • #7 / Aug 06, 2012 9:39am

    tabboy

    24 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…

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases