0

I have a multisite setup where I have a mix of custom domains and subdomains of the primary site. The majority of my custom domains automatically redirect from www to non www but I have one client that wants it to work the other way, i.e. you type somedomain.com and it redirects to to www.somedomain.com.

I've tried the mu-domain-mapping plugin which made me remove the COOKIE_DOMAIN constant, removing that prevented custom domains being able to log in (they got a cookies not enabled error).

Is there a way to do this natively in WordPress multisite?

1 Answer 1

0

You could try a rewrite rule just for his domain

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

updated my answer because I misread the question.

2
  • I would rather not use .htaccess if possible. Also, I think this would be the rule: RewriteCond %{HTTP_HOST} ^somdomain.com RewriteRule (.*) https://www.somdomain.com/$1 [R=301,L]
    – greg
    Commented Apr 30, 2018 at 20:55
  • @greg Do you have access to Apache virtual hosts? Those are the best ways. A PHP redirect will be a hack method. You could update the config in WordPress admin. namecheap.simplekb.com//SiteContents/…
    – Orlando P.
    Commented Apr 30, 2018 at 20:55

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.