https redirection

  • Unknown's avatar

    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 my theme (other options such as htaccess file do not work so hav to do it through the functions.php only)

    i tried with the following code: but it forces https only on a single page?? how do i modify it for multiple pages?

    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’);

  • Unknown's avatar

    You are in the wrong forum and need to be at Worpress.ORG for that version of the software.

  • The topic ‘https redirection’ is closed to new replies.