Https redirection - by krishnendu4august

This topic has 4 replies, 3 voices, and was last updated 9 years, 1 months ago ago by Eva Kemp

  • Avatar: krishnendu4august
    krishnendu4august
    Participant
    February 24, 2015 at 09:06

    i have installed a ssl certificate on my site …now i want to force the ssl on specific pages (checkout and my-accounts)pg id= 71890 and 71891 only and want to use http on all other pages please tell me what code do i need to put in the functions.php of royal theme

    i tried with the following code:but it forces https only on a single page??

    function force_ssl()
    {
    // Specify ID of page to be viewed on SSL connection
    if (is_page(71890) && !is_ssl () )
    {
    header(‘HTTP/1.1 301 Moved Permanently’);
    header(“Location: https://” . $_SERVER[“SERVER_NAME”] . $_SERVER[“REQUEST_URI”]);
    exit();
    }
    // All other pages must not be https
    else if (!is_page(71890) && is_ssl() )
    {
    header(‘Location: http://’ . $_SERVER[‘SERVER_NAME’].$_SERVER[‘REQUEST_URI’]);
    exit();
    }
    }
    add_action(‘template_redirect’, ‘force_ssl’);

    3 Answers
    Avatar: Brian Johnson
    Brian Johnson
    Member
    February 24, 2015 at 10:43

    Hello.
    Please provide us with ftp credetials for your site.
    With best regards
    Brian Johnson

    Avatar: krishnendu4august
    krishnendu4august
    Participant
    February 24, 2015 at 12:02

    pls note the following points b4 proceeding….

    1) i tried many many options to do the ssl or https redirection via the haccess file….but it doesn’t work
    2) the force ssl option in woocommerce settings is nt trustworthy enough and cannot be used cause it causes a false redirect loop and the payment cannot be processed…i have seen this in a couple of sites
    3) i successfully forced https for login by adding this code to the php.config….:

    /**

    define(‘FORCE_SSL_LOGIN’, true);
    */

    3) i successfully forced http on all pages and forced https for checkout page (page id= 71890)
    with the help of the code mentioned in the previous post

    4) i failed to define multiple pages and hence the my-account page in the code mentioned in the previous post

    5) i want you to help me force ssl on my-account page (id=71891) also along with the checkout page while simultaneously forcing http on all other pages…

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Support staff
    February 24, 2015 at 14:35

    Hello,

    We’re sorry, but concerning SSL redirects and https links you have to contact your hosting provider. They should give you correct code to redirect site links from http to https.

    Regards,
    Eva Kemp.

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.