Really Simple SSL

Redirection to subfolder domains redirects to https://www.domain.com/domain.com

If you are running multiple single-site WordPress websites in one hosting account, where you redirect to the correct domain using htaccess code like in this example:

RewriteEngine on 
RewriteCond $1 !domain/ 
RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule (.*) /domain/$1 [L]

The default Really Simple SSL redirect in combination with this code might cause a redirect that ends up like this:

https://www.domain.com/domain.com

To solve this, you have to add some lines to the .htaccess in your root folder. The root folder then is the folder where all folders are located with the subsites in it. It probably looks something like this:

  • root folder, with root .htaccess
    • domain1
    • domain2
RewriteCond %{HTTP_HOST} ^domain.com [NC] 
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

 

Rogier

Rogier

Related articles

8 Responses

  1. look at the default Really Simple SSL lines where exactly? I am having this same problem but the instructions to solve it doesn’t seem to be very clear.

    1. I’ve updated the article, so you don’t need these lines. Could you check if the current article is more clear? You should add those lines to the .htaccess folder in your root folder, where all subfolders/sumdomains are located.

  2. WordPress site is a subdomain. The home page of the subdomain is redirecting to the main domain.

    WP – launchny.org/lny
    Main – launchny.org

    How do I fix this?

  3. Hi, my issue is not exactly this one,l but it’s the one that seems the closest.

    I have multiple WordPress sites on my single hosting. I installed ReallySimpleSSL in one of these sites. Works fine (access through https is secured and all) but I have problems with the redirect. The subdirectory site htaccess looks like this atm:

    # BEGIN rlrssslReallySimpleSSL rsssl_version[3.2.5]

    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

    # END rlrssslReallySimpleSSL
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /planetamagicsantcugat/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /planetamagicsantcugat/index.php [L]

    # END WordPress

    And the htaccess on the root of my hosting looks like this:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    Atm there is nothing on my root (no WP site or anything, might be in the future).

    The problem is:
    https:/domain.com/planetamagicsantcugat/ works fine.
    but
    http:/domain.com/planetamagicsantcugat/ redirects to https:/domain.com/

    I am guessing I am missing something on my root htaccess. What is the best practice here to fix it?

    Thanks.

    1. Hi,

      is there a difference in redirect when using http:// and http://www? What you could try is editing the following line in your subdirectories .htaccess file:

      RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

      to this:

      RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

      The {REQUEST_URI} parameter is slightly different from the %1 and might solve this issue. You could try the same for the RewriteRule ^(.*)$ http://%1/$1 [R=301,L] line, changing it to RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] as well.

      Mark

Leave a Reply

Subscribe