Port number (80) added to URL upon M2P login from protected content page

If you go to the https://www.+++academy.com, scroll down and click on "My+++land" link in the footer, you'll be taken to "Protected Content" page with a login form. When you try to login there using test user (see additional notes in chat) you'll notice that port number :80 is added to URL resulting in a redirect to non working site.

It's been suggested that it's something wrong with SSL certificate implementation but WP Engine confirmed that it's setup fine. They were also able to replicate the same issue on a staging site and run a full conflict test there but it didn't help in any way.

The .htaccess is default apart from "Prevent Information Disclosure" rules added by Defender.

  • Kasia Swiderska
    • Support nomad

    Hello Heather,

    I have escalated this task to our Second Line Support developers (our coding experts) as I'm not able to find reason for this weird redirect (I checked database, htaccess, wp-config.php file) and everything seems correct there.
    I performed test on my WPEngine account but I wasn't able to replicate this issue there.

    I will pass all the information to devs and they will investigate this issue and let us know where is problem.

    kind regards,
    Kasia

  • Ivan
    • Developer

    Hi Heather !

    I fixed this issue on your site. As a quick workaround, I replaced one line in {wordpress_folder}/wp-content/plugins/membership-2/lib/wpmu-lib/inc/class-thelib-net.php file on your site (59th line), from
    ( $is_ssl && '443' != $_SERVER['SERVER_PORT'] )

    to
    ( $is_ssl && !in_array( $_SERVER['SERVER_PORT'], array( '80', '443' ) ) )

    Actually, it didn't help because you also use Hustle Pro plugin which uses the same library. So, I did the same change in {wordpress_folder}/wp-content/plugins/hustle/lib/wpmu-lib/inc/class-thelib-net.php file. And it works fine now.
    Also, this change will be able in the next versions of the plugins.

    Best,
    Ivan.

  • forthgear
    • The Incredible Code Injector

    Hi Ivan, I just wanted to give you some feedback, we are having the same problem listed above on version 1.1.2 of Membership 2. It's applying port :80 on redirect no matter what we do.

    In the end, I removed the following code from the file you mentioned above:

    if ( ! isset( $_SERVER['SERVER_PORT'] ) ) {
    				if ( $is_ssl ) { $_SERVER['SERVER_PORT'] = '443'; }
    				else { $_SERVER['SERVER_PORT'] = '80'; }
    			}
    
    			if ( ( ! $is_ssl && '80' != $_SERVER['SERVER_PORT'] ) ||
    				( $is_ssl && '443' != $_SERVER['SERVER_PORT'] )
    			) {
    				$cur_url .= ':' . $_SERVER['SERVER_PORT'];
    			}

    I'm a little confused as to why you are even setting the port in the URL...the Server should be handling the redirect to SSL, not your plugin...

    I could be mistaken here and this is needed to help the plugin function elsewhere. But with removing it, it solved our redirect problem.

    Can you please advise a little more as to what the purpose is of having this code in there. And if it needs to be in there what is the fix as the current version still has the issue.

  • Ivan
    • Developer

    Hi forthgear !

    The version 1.1.2 was released January 8, 2018. We found this issue January 23, 2018. We just did not have time to do it :slight_smile:
    It should be fixed in the next versions.

    I'm a little confused as to why you are even setting the port in the URL...the Server should be handling the redirect to SSL, not your plugin...

    It isn't related to the SSL, it's about the port. Some sites use the special port and if we won't add it - it will create some issues. Of course, a majority of sites use default ports: 80 for HTTP and 443 for HTTPS. And your site looks like the site is not using default port (80 for HTTPS). So, it's why does this happen. But we will fix it soon.

    Best,
    Ivan.

  • gvincke
    • Design Lord, Child of Thor

    I also removed the lines to fix the problem
    if ( ! isset( $_SERVER['SERVER_PORT'] ) ) {
    if ( $is_ssl ) { $_SERVER['SERVER_PORT'] = '443'; }
    else { $_SERVER['SERVER_PORT'] = '80'; }
    }

    if ( ( ! $is_ssl && '80' != $_SERVER['SERVER_PORT'] ) ||
    ( $is_ssl && '443' != $_SERVER['SERVER_PORT'] )
    ) {
    $cur_url .= ':' . $_SERVER['SERVER_PORT'];
    }

  • Ivan
    • Developer

    Hi forthgear !

    I checked it and I see it has already implemented these changes. If it's not working for you - could you create a separate thread here and provide additional login credentials? I can look into it more.

    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ivan Svyrskyi"

    In the Message box, please provide the following:

    link back to this thread for reference
    any other relevant urls

    Admin login:
    Admin username
    Admin password
    Login url

    FTP/SFTP credentials
    host
    username
    password
    (and port if required)

    Note: Don't send any credentials via this forum because it's public forum.

    Best,
    Ivan.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.