WordPress.org

Ready to get started?Download WordPress

Forums

WordPress HTTPS (SSL)
Redirects to Homepage on pages where SSL is required (5 posts)

  1. arashster
    Member
    Posted 1 year ago #

    I'm using the WordPress HTTPS plugin on a site that is using Cloudflare SSL Flexible SSL proxy.

    I can access any given URL by using https, but when I force SSL on a particular page using either the "Secure post" option on each page, or by entering the URL in the SSL filter, I get redirected back to the home page.

    If I disable those options and visit the page directly using SSL however, it works.

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

  2. Brian
    Member
    Posted 1 year ago #

    I'm having this exact problem as well.

    On mediatemple.

    Is there a fix?

  3. arashster
    Member
    Posted 1 year ago #

    I too am on media template.

    For the meantime, I implemented my own setting in functions.php

    Basically, I check for a custom attribute called 'ssl' on my page, and if it exists, it redirects to the SSL page.

  4. Geet Jacobs
    Member
    Posted 1 year ago #

    I am running into the same issue, also on Media Temple. @arashster can you post the function you are using?

    Thanks!

  5. arashster
    Member
    Posted 1 year ago #

    function checkSsl() {
    	if (g('ssl') != '' && g('ssl') != 'off' && g('ssl') != '0' && $_SERVER['HTTPS'] != 'on') {
    		$vurl = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    		header("Location: " . $vurl);
    		die();
    	}
    }
    
    function g($attribute, $random=false, $page='') {
    	global $post;
    	global $post_attributes;
    	$return = '';
    	if ($page == '') {
    		$page = $post->ID;
    	}
    	if($post_attributes == '') {
    		$post_attributes = array();
    	}
    	if($post_attributes[$page] == '') {
    		$post_attributes[$page] = get_post_custom($page);
    
    	}
    	if (!$random) {
    		$return = $post_attributes[$page][$attribute][0];
    	} else {
    		$r = $post_attributes[$page][$attribute];
    		if (is_array($r)){
    	    	$x = array_rand($r);
    		    $return = $post_attributes[$page][$attribute][$x];
    		}
    	}
    	return $return;
    }

    put the two functions in functions.php

    g() is a shorthand function I use to get the custom attribute for the current page or any other page.
    just put checkSsl() at the top of page.php or any other page template and it should redirect. Quick and dirty, I know.

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.