Search code examples
wordpresshttp-redirectmultisite

wordpress multisite domain mapping redirects


I just added a new site to my wordpress multisite and if www wasnt in front of the url, it redirected to my main site.

i added the following code to my htaccess

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

and now my secondary site works just fine, however my main site now redirects to the secondary one.

does anyone have any suggestions for me?

thanks


Solution

  • Yours will rewrite any URL without www.example.com to the new domain.

    This worked for me, to rewrite all non www to example.com.

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

    Also, for some reason, I needed to refresh the permalinks in the child site as well.