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]

 

Simple and Performant Security.
Easily improve site security with WordPress Hardening, Two-Factor Authentication (2FA), Login Protection, Vulnerability Detection and SSL certificate generation.