directing non-www to www domains in multisite

Used the domain mapping plugin to map my subsite domains and it worked perfectly. But the resulting sites are non-www and I'd like to redirect them to www.

I tried

RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule (.*)$1 [R=301,L]

for one of the domains, but I got "this page isn't redirecting properly".

My current .htaccess looks like this:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

AddType text/x-component .htc

The first part is because the main site was originally an html site. I tried putting the subsite redirect after that part and then before that part and neither worked.

Any ideas?

  • aecnu
    • WP Unicorn

    Greetings flojnel,

    Rather then get into a long debate about this very topic once again I have decided to put it out there plain and simple.

    Our Domain Mapping plugin lead developer said in another ticket regarding this same issue:
    It is wordpress multisite itself that strips out the www from the domain name, not the domain mapping plugin - so attempting to have redirecting to will then result in WP stripping out the www. and redirecting back to - which as you will no doubt see will result in an infinite redirect.

    However, my orders from headquarters are to resolve any ticket I can regardless of where the plugin or solution comes from, therefore I offer you to try out:

    Please advise if this does not work out for you by simply check marking not resolved below and be sure to post any errors, symptoms, etc. that are relevant to this thread.

    Thank you for being a WPMU Dev Member!

    Cheers, Joe

  • flojnel
    • Site Builder, Child of Zeus

    I started thinking about this and decided it's just not that big of an issue. The domain gets properly redirected, which is the main thing. I just know clients tend to like the www. But since the tendency is away from it anyway, I'm not going to worry about it. Just do some client ed.

    Thanks for the explanation of the infinite redirect!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.