Support » Networking WordPress » Redirecting non-www to www revisited

  • Resolved MattV


    I´m using WordPress Multisite with subdomains and the WordPress MU Domain Mapping plugin.

    My main site´s URL is listed as (it was suggested by WP to leave out the www during the installation).

    At the moment my site and all mapped sites are redirected from: to

    I´d like to have it the other way around: to

    I´ve found various solutions (listed below), each of them working at a different level: DNS, .htaccess, WP database or domain mapping.

    I hope someone can explain at which level this redirect should take place so I can find the right solution.

    The options I found:

    1. Redirect the non-www URL to the www using .htaccess
      # Redirect to www.
      RewriteCond %{HTTP_HOST} !^www\.
      RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

      (This causes an infinate loop as WP then redircets the www to non-www)

    2. Define a new constant in the wp-config file including the www:


    3. Use the Domain mapping plugin: add a new entry, with the same Site ID as the entry.
    4. Add a new CNAME record to your DNS, pointing www to your main domain

    Many thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    With MultiSite it’s a BIT more complicated, since you have multiple places in the database where the domain is set to

    I would strongly recommend leaving it the heck alone if it’s working. Why do you want to change it?

    I´ve moved an exisiting site from a single WP install to WP Multisite. The old URL always had the www included, like:

    For continuity I´d like to keep the same URL structure (with the www inluded I mean).

    If editing the DB is not a good idea, would any of the other options (htaccess/cname) be a “preferred” solution?

    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    Yeah, it’s not the same thing, editing single site as multisite with those changes.

    Frankly, the www doesn’t matter, so long as your old URLs are seamlessly redirected to the new ones.

    The best way if you REALLY want to do this is to edit your wp-config and THEN go through the database and find every instance of and add in www. Then go back and look again, cause you may have missed one.

    It’s seriously a pain in the ass. Unless you really, truly, have to. Don’t. if it’s just cause you like www better, I strongly suggest you lean to love sans www 🙂 Any mismatch, any missed file, can cause your site to break. Badly.

    Ok that´s very clear 🙂

    So far I´ve this:

    • htaccess: no option, this will cause an infinite redirect loop
    • wp databse: very risky, better not mess with it

    Would the other options be a solution? (Point 3 and 4 in my first post: a new entry in the domain mapping plugin or adding a CNAME record)

    (There are so many questions regarding this topic that I thought it would be good to cover all the options in one single thread. Also for others who´ll have the same question. I really aprictae your help!!
    – Thanks!)

    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    Domain mapping or CNAME MIGHT work, but it also may cause the same problem as htaccess :/ You’ll have to test and check, as I’ve not tried them. I HAVE done the domain, and it’s a pain.

    Andrea Rennick


    Customer Care at Copyblogger Media and Studiopress

    Use the Domain mapping plugin: add a new entry, with the same Site ID as the entry.

    this is the simplest solution. if you’re mapping the site already, you can just add the domain again with the www.

    Thanks Ipstenu & Andrea, it´s very clear now!

    Anyone an idea how to fix this for the primary URL?
    Since this is site ID 1, I tried to add and set it as primary. But the record isn’t saved.

    Most important is that my main site shows: instead of

    Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    ruben86 – This topic is marked resolved, which means you need to make your OWN topic for yourself 🙂

    You can’t map the MAIN URL via the domain mapping plugin. You would need to essentially change the URL on your site, and it’s a pain in the butt.

    Oh, sorry! In that case I leave it as it is… Thanks anyway

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Redirecting non-www to www revisited’ is closed to new replies.