WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Domain Mapping
[resolved] How to make www. and no www. Go to same site, for all sites? (2 posts)

  1. Michael Ecklund
    Member
    Posted 1 year ago #

    I've been adding my sites like:

    Site ID: 3
    Domain: domain.com
    Primary? No
    Site ID: 3
    Domain: www.domain.com
    Primary: Yes

    I've also tried adding:

    Site ID: 3
    Domain: www.domain.com,domain.com
    Primary? Yes

    But when you go to domain.com, it stays as domain.com. I want to force www.domain.com when domain.com is visited.

    Am I doing something wrong with my domain mapping?

    http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/

  2. Michael Ecklund
    Member
    Posted 1 year ago #

    Answered from this thread.

    Summary:
    The .htaccess redirect for www/non-www...

    # www redirect
    RewriteCond %{HTTP_HOST} ^subdomain.com
    RewriteRule ^(.*)$ http://www.subdomain.com/$1 [R=301,L]

    Put it ABOVE your WordPress rules on domain.com. Should work.

    Example:

    RewriteEngine On
    
    # DOMAIN #1 - Redirect non-www urls to www
    RewriteCond %{HTTP_HOST} ^domain1.com
    RewriteRule ^(.*)$ http://www.domain1.com/$1 [R=301,L]
    
    # DOMAIN #2 - Redirect non-www urls to www
    RewriteCond %{HTTP_HOST} ^domain2.com
    RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]
    
    # DOMAIN #3 ... ETC - Redirect non-www urls to www
    RewriteCond %{HTTP_HOST} ^domain3.com
    RewriteRule ^(.*)$ http://www.domain3.com/$1 [R=301,L]
    
    RewriteBase /
    RewriteRule ^index\.php$ - [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).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    Marking topic as resolved. It would be nice if someone could explain how to force a trailing slash to each of my domains as well (if not present).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic