WordPress.org

Ready to get started?Download WordPress

Forums

WordPress HTTPS (SSL)
[resolved] WordPress HTTPS: This webpage has a redirect loop (10 posts)

  1. aacook
    Member
    Posted 2 years ago #

    I've used this plugin before, but today I am getting this error:
    This webpage has a redirect loop.

    I tried to debug for a few hours... looking all over Google, on this forum, etc... and I've had zero luck.

    Is this a bug with the latest version?

    -I am not using Shared SSL
    -Tried updating all plugins and to the latest wordpress core
    -Tried deactivating all plugins except this plugin
    -I know SSL works since I can browse to a file directly on the server and it's served up via SSL just fine

    Anyone else experiencing this issue?

  2. Mvied
    Member
    Plugin Author

    Posted 2 years ago #

    Hey aacook,

    Redirect loops happen on sites for a number of reasons. Please provide the settings you have enabled and a link to a broken page.

    Thanks,
    Mike

  3. timbunch
    Member
    Posted 2 years ago #

    I started having this issue after upgrading as well. I quickly downgraded my public site and it works again. 1.9.0 and 1.9.1 both have the same issue for me.

    More Details

    1. Redirect loops only happen on non-ssl pages
    2. Redirect loops only happen when using the option Force SSL Exclusively
    3. Version 1.8 didn't have the issue

    So somewhere that function (or related function) has changed, causing the redirect.

  4. timbunch
    Member
    Posted 2 years ago #

    I replaced the updated function (1.9) with the outdated function (1.8) and my issue is resolved. However, the redirect function no longer works at that point either.

    function redirect version 1.8
    [Code moderated as per the Forum Rules. Please use the pastebin]

    function redirect version 1.9

    [Code moderated as per the Forum Rules. Please use the pastebin]

  5. Mvied
    Member
    Plugin Author

    Posted 2 years ago #

    Hi timbunch,

    Well, that makes sense considering I completely changed the argument in that method from boolean in 1.8.5 to either 'http' or 'https' in 1.9. I wouldn't expect the old method to work. :P

    I imagine what's happening is is_ssl method is throwing a false positive due to some kind of proxying going on with your server configuration. The redirect loop is most likely caused by this conditional in the is_ssl method.

    if ( isset($_SERVER['HTTP_X_FORWARDED_SERVER']) && !is_ssl() && strpos($this->https_url, $_SERVER['HTTP_X_URL_SCHEME'] . '://' . $_SERVER['HTTP_X_FORWARDED_SERVER']) !== false ) {
    	return true;
    }

    Try replacing the method with this one:

    function is_ssl() {
    	// Some extra checks for proxies and Shared SSL
    	if ( $this->shared_ssl == 1 && isset($_SERVER['HTTP_X_FORWARDED_SERVER']) && !is_ssl() && strpos($this->https_url, $_SERVER['HTTP_X_URL_SCHEME'] . '://' . $_SERVER['HTTP_X_FORWARDED_SERVER']) !== false ) {
    		return true;
    	} else if ( $this->shared_ssl == 1 && !is_ssl() && strpos($this->https_url, $_SERVER['HTTP_HOST']) !== false ) {
    		return true;
    	}
    	return is_ssl();
    }

    Let me know if that prevents the redirect loops.

    Thanks,
    Mike

  6. yonisink
    Member
    Posted 2 years ago #

    Mike-
    I came here with the exact same problem and replaced the function with your new one and it works great. Time for a new .001 version!
    Thanks much for a great plugin and greater support!

  7. Mvied
    Member
    Plugin Author

    Posted 2 years ago #

    Hi yonisink,

    Would you let me conduct some tests on your site? I'd like to be able to figure out exactly why this conditional is returning true. I have a pretty good idea, but it doesn't seem to make sense.

    If you want, you can email me an admin login to mike[at]mvied[dot]com. If you don't want to create an admin account for me on your live site, a separate WordPress install on the same server would work. I'd love to be able to test some bug fixes in it. The code that I proposed really isn't viable for all server configurations.

    Thanks,
    Mike

  8. yonisink
    Member
    Posted 2 years ago #

    Mike - I emailed you

  9. aacook
    Member
    Posted 2 years ago #

    Hi Mike, I also emailed you a login you can use for debugging.

    Thanks!

  10. Mvied
    Member
    Plugin Author

    Posted 2 years ago #

    For the record, aacook's redirect issue was being caused by his theme always redirecting back to HTTP. Very strange behavior for a theme.

    Yonisink's issue was a bug in 1.9.1 that will be fixed in 1.9.2 which will be released very soon.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic