404 pages Redirect rules

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 the example this:

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:


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]


Related Articles


  • Anan Mohammed

    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.

    • Rogier Lankhorst

      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.

  • Laura Liebel

    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?

    • Mark Wolters

      Hi Laura,

      It seems to be working fine now, do you still experience issues? If so, when do you experience these issues?

      • Laura Liebel

        Just deleted all history in chrome. Seems ok now. thanks.

  • Chaoscontrol

    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.
    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?


    • Mark Wolters


      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.


      • Chaoscontrol

        Epic! It worked great! Thank you SO much.

        www version did the same type of redirect.

Leave a Comment