WordPress.org

Ready to get started?Download WordPress

Forums

How to Force SSL for a Single Form Page (9 posts)

  1. bryansmith78
    Member
    Posted 5 years ago #

    Hello, I wanted to ask if anyone knows of a method to make only specific form pages on a WordPress website force SSL? I have found
    a lot of info for SSL of Admin section or the entire website but nothing for just forcing https on individual pages that contain forms. I already have a certificate installed and https working well on the website.
    Any guidance on a solution for this problem would be very appreciated!

  2. melvins138
    Member
    Posted 5 years ago #

    Forgive me for bumping this, but I to would like to know how to have a single page containing a form to be on SSL, but not the rest of the site.

    I also would like to use WP 2.6

    Any help would be appreciated.

    Thanks.

  3. Christiaan
    Member
    Posted 5 years ago #

    I'm also interested in this, but for v2.7

  4. Christiaan
    Member
    Posted 5 years ago #

  5. dicedtomatoe
    Member
    Posted 5 years ago #

    Christiaan I've been having the same problem I think I can help you!
    Are you hosting with MediaTemple? I was able to make a single page with a form secure!
    I do believe it is a media temple thing. In the wp-includes/cononial.php file you have to change 'HOST_NAME' to 'SERVER_NAME' on line 48.

  6. Christiaan
    Member
    Posted 5 years ago #

    Hi diced, no I'm with Hostpapa. Your fix seems a bit strange though. How does that force a single page to https? How do you choose which page you want to force to https?

  7. yaphi
    Member
    Posted 5 years ago #

    I am not with mediatemple and I am having the same problem. Please post a fix.

  8. yaphi
    Member
    Posted 5 years ago #

    I ended just forcing this if statement to always set it to https://

    line 47, /wp-includes/canonical.php (WordPress 2.7)

    from

    $requested_url = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';

    to

    $requested_url = ( !empty($_SERVER['HTTPS'] ) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'https://';

    I really hope someone figures this out.

  9. Kevin Leary
    Member
    Posted 4 years ago #

    I think I found a temporary fix for this. I managed to get one page working with SSL and have the rest of the site be outside of https:// for speed reasons.

    I used the HTTPS for WordPress Plugin to get the page working with SSL. I added some custom PHP to header.php to take the rest of the site out of https://.

    http://wordpress.org/extend/plugins/https-for-wordpress/

    After you activate the plugin add this PHP to header.php, or it may work in functions.php as well.

    <?php
    // Force SSL for Incorporate Online
    if(is_page('incorporate-online')) {
    	if($_SERVER["HTTPS"] != "on") {
    		$newurl = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    		header("Location: $newurl");
    		exit();
    	}
    } else {
    	if($_SERVER["HTTPS"] == "on") {
    		$newurl = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    		header("Location: $newurl");
    		exit();
    	}
    }
    ?>

    Where "incorporate-online" is the slug of the page you want SSL running on.

    I hope this helps, once I launch this site shortly I can send links to a working example.

Topic Closed

This topic has been closed to new replies.

About this Topic