ERR_TOO_MANY_REDIRECTS on subdomain

Home Forums General issues ERR_TOO_MANY_REDIRECTS on subdomain

This topic contains 12 replies, has 2 voices, and was last updated by  Ben German 3 months, 2 weeks ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #21078 Reply

    Benjamin German

    Hi Rogier,

    First of all, THANK YOU for making such a simple yet awesome plugin! I’d been running around in circles until I had installed it! I am having a little issue with the redirects on the subdomains however. I have tried a few different options all with slight issues:

    option 1: The main domain and all subdomains use HTTPS (currently being used)
    Problem: I get ERR_TOO_MANY_REDIRECTS on subdomain (https://subdomaintest.foldsofhonor.org/)

    # BEGIN rlrssslReallySimpleSSL rsssl_version[2.4.3]
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    # END rlrssslReallySimpleSSL
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ wp/$1 [L]
    RewriteRule . index.php [L]
    
    </IfModule>
    
    # END WordPress

    option 2: target specific subdomians
    Problem: The primary site http://www.foldsofhonor.org renders over http but when going to https, loses all formatting because references to the assets (images, scripts, css etc) still points at http. https isn’t forced.

    # BEGIN rlrssslReallySimpleSSL rsssl_version[2.4.3]
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    #wpmu rewritecond www.foldsofhonor.org
    RewriteCond %{HTTP_HOST} ^foldsofhonor\.org [OR]
    RewriteCond %{HTTP_HOST} ^www\.foldsofhonor\.org [OR]
    #end wpmu rewritecond www.foldsofhonor.org
    #wpmu rewritecond southerncalifornia.foldsofhonor.org
    RewriteCond %{HTTP_HOST} ^southerncalifornia\.foldsofhonor\.org [OR]
    RewriteCond %{HTTP_HOST} ^www\.southerncalifornia\.foldsofhonor\.org [OR]
    #end wpmu rewritecond southerncalifornia.foldsofhonor.org
    #wpmu rewritecond subdomaintest.foldsofhonor.org
    RewriteCond %{HTTP_HOST} ^subdomaintest\.foldsofhonor\.org [OR]
    RewriteCond %{HTTP_HOST} ^www\.subdomaintest\.foldsofhonor\.org 
    #end wpmu rewritecond subdomaintest.foldsofhonor.org
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    # END rlrssslReallySimpleSSL
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ wp/$1 [L]
    RewriteRule . index.php [L]
    </IfModule>
    # END WordPress

    Below is what my wp-config looks like:

    <?php
    
    //Begin Really Simple SSL Load balancing fix
    if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"] ) && "https" == $_SERVER["HTTP_X_FORWARDED_PROTO"] ) {
    $_SERVER["HTTPS"] = "on";
    }
    //END Really Simple SSL
    /**
     * The base configuration for WordPress
     *
     * The wp-config.php creation script uses this file during the
     * installation. You don't have to use the web site, you can
     * copy this file to "wp-config.php" and fill in the values.
     *
     * This file contains the following configurations:
     *
     * * MySQL settings
     * * Secret keys
     * * Database table prefix
     * * ABSPATH
     *
     * @link https://codex.wordpress.org/Editing_wp-config.php
     *
     * @package WordPress
     */
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'xxxxxxxx');
    /** MySQL database username */
    define('DB_USER', 'xxxxxxxx');
    /** MySQL database password */
    define('DB_PASSWORD', 'xxxxxxxx!');
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define('AUTH_KEY',         'put your unique phrase here');
    define('SECURE_AUTH_KEY',  'put your unique phrase here');
    define('LOGGED_IN_KEY',    'put your unique phrase here');
    define('NONCE_KEY',        'put your unique phrase here');
    define('AUTH_SALT',        'put your unique phrase here');
    define('SECURE_AUTH_SALT', 'put your unique phrase here');
    define('LOGGED_IN_SALT',   'put your unique phrase here');
    define('NONCE_SALT',       'put your unique phrase here');
    /**#@-*/
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each
     * a unique prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix  = 'wp_';
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     *
     * For information on other constants that can be used for debugging,
     * visit the Codex.
     *
     * @link https://codex.wordpress.org/Debugging_in_WordPress
     */
    define('WP_DEBUG', false);
    /* Multisite */
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'www.foldsofhonor.org');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIE_DOMAIN', '');
    define('COOKIEPATH', '');
    define('SITECOOKIEPATH', '');
    /* That's all, stop editing! Happy blogging. */
    /*
    define( 'DISALLOW_FILE_EDIT', true );
    define( 'DISALLOW_FILE_MODS', true );
    define('WP_AUTO_UPDATE_CORE', true);
    */
    define( 'WP_MEMORY_LIMIT', '96M' );
    define( 'WP_MAX_MEMORY_LIMIT', '256M' );
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

    Have you any suggestions on what else I could try or what might be causing these type of redirects?

    Thank you in advance for all your help!

    #21086 Reply

    Hi Benjamin,

    I would first focus on your first option: redirect everything to https. That would seem the easiest solution. So in that case we need to solve the redirect loop you are getting. Some possible causes are:
    – Cloudfflare: in most cases Cloudflare does not cause any issues, but I’ve seen some cases where deactivating Cloudflare solved the issue. Maybe a setting needs to be adjusted.
    – Your SSL certificate:https://www.ssllabs.com/ssltest/analyze.html?d=subdomaintest.foldsofhonor.org
    In the scan you can see you have chain issues. This can sometimes cause issues with redirect loops, so should be fixed anyway.

    #21093 Reply

    Ben German

    Thanks for such a fast reply Rogier! These are great starting points. The server was indeed using CloudFlare. (I thought is was just another hosting company so when I asked the client to point the IP address, I had no idea it was going through their network.

    I have changed this to DNS only, hoping this would have an impact, but I am still seeing the ERR_TOO_MANY_REDIRECTS issue.

    On to your next suggestion about the SSL labs tester in the link above… I notice that the main error states “Certificate #2: RSA 2048 bits (SHA256withRSA) No SNI” then shows “Common names Plesk MISMATCH”. Have you come across this before or have a solution for it?

    Again thank you in advance!

    #21108 Reply

    I haven’t seen that error to be a problem, so I don’t think that is causing the issue. I would focus on the chain errors which often can cause issues.

    Did you try what happens if you remove the redirect altogether? If the issue is caused by the .htaccess redirect we might try a different redirect.

    #21109 Reply

    Ben German

    If I remove it altogether the site the site won’t load over https. It loads fine over http, but when you look in the source, the code references the WordPress site_id (e.g http://www.foldsofhonor.org/) and loses all formatting because it references the assets (images, scripts, CSS etc). I figured the easiest thing was to go into the database and change the site_id to https://www.foldsofhonor.org/. This would lead to ERR_TOO_MANY_REDIRECTS again on not only the subdomains but the main site as well.

    The only thing I could do to get it to work was to use your plugin… and it works a treat for the main site, but not for the subdomain.

    Do you have any other ideas? I’m really grateful for all the suggestions you have had so far!

    #21135 Reply

    If you look in the settings of the subdomain, is the site_url and home_url on https? Really Simple SSL changes the siteurl and homeurl to https when on SSL, but from what you’re describing, it almost seems as if this is not the case.

    #21401 Reply

    Ben German

    Thanks Rogier,

    I tried both http and https but both have the same ERR_TOO_MANY_REDIRECTS problem. I thought it might be my cookies or something, but the same happened when trying it on different browsers in different environments. I used browserstack.com and no matter what I try I get the same result. The .htaccess looks right at the top of this thread right?

    Can you think of any other suggestions?

    #21402 Reply

    Does the subdomain have plugins that are different from the main site?

    From what you describe, the setup is identical to the main site, so maybe you need to look at the differences: plugins, theme. If there are different plugins, you could deactivate those to test.

    Another thing you could try is a specific cloudflare redirect instead of the current one, as you are on cloudflare, which could cause some problems:


    RewriteEngine on
    RewriteCond %{HTTP:CF-Visitor} ‘”scheme”:”http”‘
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    #21480 Reply

    Ben German

    Rogier, You sir are a genius!

    That is exactly what the problem was!

    This is what the .htaccess looks like now

    
    # BEGIN rlrssslReallySimpleSSL rsssl_version[2.4.3]
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    <strong>RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'</strong>
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    # END rlrssslReallySimpleSSL
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ wp/$1 [L]
    RewriteRule . index.php [L]
    </IfModule>
    # END WordPress
    <IfModule mod_php5.c>
    php_value post_max_size           10M
    php_value upload_max_filesize     4M
    php_value memory_limit            500M
    </IfModule>
    

    Never did I think that the issue was not todo with our server, SSL or theme code but the way the A record had been pointed to us! I have been building websites for over 18 years and I have never come accross this before.

    Thank you again so much!

    #21481 Reply

    Ben German

    it should be :

    # BEGIN rlrssslReallySimpleSSL rsssl_version[2.4.3]
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    # END rlrssslReallySimpleSSL
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ wp/$1 [L]
    RewriteRule . index.php [L]
    </IfModule>
    # END WordPress
    <IfModule mod_php5.c>
    php_value post_max_size           10M
    php_value upload_max_filesize     4M
    php_value memory_limit            500M
    </IfModule>

    Please ignore the
    <strong> </strong>

    #21482 Reply

    Thanks for the update!

    Great it’s solved. Is the SSL cert from Cloudflare, or is it your own? I wonder why it works in most cases, but sometimes needs this fix.

    I’ll add this new code to the plugin as well.

    For now, please enable “stop editing the .htaccess” in your settings, so the plugin won’t overwrite it.

    #21492 Reply

    I’ve created a new beta-release that checks for this situation as well. If you’d like to test it please send me an email, so I can send you a copy. rogier( at ) really-simple-ssl.com

    #21727 Reply

    Ben German

    I just unchecked the box and it broke the other subdomains giving it the same error. The fix for this was to deactivate the plugin, then reactivate the plugin and uncheck the “stop editing the .htaccess” box in settings.

    I thank re-added
    RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'

    phew!

Viewing 13 posts - 1 through 13 (of 13 total)
Reply To: ERR_TOO_MANY_REDIRECTS on subdomain
Your information: