How to Disable ssl for subdomains generated by multisites (please check description)

I had installed pro-sites plugin, and everything was working fine, but last 2-3 days when i did some tweaks (added 2-3 plugins including domain mapping, w3tc) the subdomains generated are being redirected to https.

I want SSL for my main domain (https://mywebsite.com) and non https (no ssl) on http://123.mywebsite.com)

I've checked all the other related threads, but that didn't worked.
I've tried disabling all the plugins and then generating site, again that did'nt worked.
Anyone pleae help, if they know how to solve this problem

  • Fabio Fava
    • WordPress DevOps

    Hey Mohit !

    Take a look on your site's .htaccess and wp-config.php files, you may find some lines to force all requests for HTTPS. Removing these lines would allow you to choose HTTP or HTTPS when accessing the pages, without forcing them to one or the other.

    On your WordPress root folder's .htaccess file:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    Or, depending on your server's setup, it will be like this:

    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

    And on your WordPress root folder's wp-config.php file:

    define('FORCE_SSL_ADMIN', true);

    Hope it helps, cheers!

  • Oguz
    • QA Engineer

    Hey Mohit ,

    Hope you're well.

    Beside Fabio Fava recommendations maybe you can try a mu plugin to force subsites to HTTP. You just need to create the mu-plugins folder first if it's not there in the wp-content folder. Then create a PHP file like force_http.php and place this codes inside it;

    <?php
    function wpmu_force_http() {
        if ( !is_main_site() && is_ssl() ) {
            wp_redirect( "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
            exit;
        }
    }
    
    add_action('plugins_loaded', 'wpmu_force_http' );

    I hope it helps.

    Cheers,
    Oguz

    • Mohit
      • WPMU DEV Initiate

      Hello! I did this.
      But now whenever I enter the login credentials and submit. It says

      ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.

      I did enable the cookies, then it logs me in, but everytime it asks for same thing.
      please help

  • Nastia
    • Support Rock Star

    Hello Mohit

    Hope all is well!

    Please add the following line into the wp-config.php file, Right above /* That's all, stop editing! Happy blogging. */

    define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );
    /* That's all, stop editing! Happy blogging. */

    If this will not work. Add the following code inside the functions.php of the active theme:

    setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN);
    if ( SITECOOKIEPATH != COOKIEPATH ) setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN);

    Hope this will help!

    Cheers,
    Nastia

  • Mohit
    • WPMU DEV Initiate

    After adding all the above code
    Update:
    the mysite.com is on SSL and is working fine as before
    but the login can be accessed error free from only the subdomain admin login
    example:
    (mysite.com/wp-admin) .> https error
    (123.mysite.com/wp-admin ) login -> no error
    Error on loggin in from the main site

    Anyone who knows how to solve this, please help
    Thanks

  • Oguz
    • QA Engineer

    Hey Mohit ,

    Hope you're well.

    I think we are thinking in a wrong way the problem. Let me explain why;

    We are trying to redirect an HTTPS site to HTTP site from host but that URL is never reaching the host. Because when you type an https URL browser first checks the SSL certificate then reaches the host, so in your case, because of there is no certificate none of redirect solution work. Because as I said the browser never will reach the host to read the redirection rules.

    So instead of trying to find a redirection way from HTTPS to HTTP, we should focus on why it is redirecting subsites to HTTPS. First, can you check Network Admin > Sites > One of the subsite Edit link and check the "Site Address (URL)" field. Is that https? Then also check Settings tab Siteurl/Home fields.

    If this not helps, can you check how did you add SSL to your main domain? Maybe your hosting provider (domain manager) redirect all subdomains to HTTPS version automatically.

    Cheers,
    Oguz

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.