I'm working on a multisite Craft CMS 3 website. When I'll go to www.site-a.com (default) and www.site-b.com this works fine. The correct sites and templates are displayed. But if I'll go to site-b.com (without www) I'll redirected to www.site-a.com. The sites are not multilangual and doesn't have a seperated webroot. I'll point the domains to the same webroot. This is how I'll set it up in the general config:

   'production' => [
        'env'                   => 'production',
        'siteUrl'               => array(
            'default'           => 'https://www.site-a.com/',
            'second'            => 'https://www.site-b.com/'

In my htaccess I'll force to use to the www domain, like this:

    # -----------------------
    # Force www
    # -----------------------
    RewriteCond %{SERVER_ADMIN} !^dev$
    RewriteCond %{HTTP_HOST} !^localhost$
    RewriteRule ^(.*)$ https://www.{HTTP_HOST}.com/$1 [L,R=301,NC]

What I'll do wrong?

1 Answer 1


The problem is that the force ww redirect isn't setup correctly. This must be setup like this:

    # Force www
    # -----------------------
    RewriteCond %{HTTP_HOST} ^domain-a.com [NC]
    RewriteRule ^(.*)$ https://www.domain-a.com/$1 [L,R=301,NC]

    RewriteCond %{HTTP_HOST} ^domain-b.com [NC]
    RewriteRule ^(.*)$ https://www.domain-b.com/$1 [L,R=301,NC]

Also both domains must point to the same server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.