I´m using WordPress Multisite with subdomains and the WordPress MU Domain Mapping plugin.
My main site´s URL is listed as http://mainsite.com (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:
www.domain.com to domain.com
I´d like to have it the other way around:
domain.com to www.domain.com
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:
- Redirect the non-www URL to the www using .htaccess
(This causes an infinate loop as WP then redircets the www to non-www)# Redirect to www. RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] - Define a new constant in the wp-config file including the www:
define('WP_SITEURL','http://www.mainsite.com');
- Use the Domain mapping plugin: add a new entry http://www.mainsite.com, with the same Site ID as the mainsite.com entry.
- Add a new CNAME record to your DNS, pointing www to your main domain
Many thanks!