WordPress.org

Support

Support » Plugins and Hacks » WordPress MU Domain Mapping » [Resolved] How to make www. and no www. Go to same site, for all sites?

[Resolved] How to make www. and no www. Go to same site, for all sites?

Viewing 1 replies (of 1 total)
  • 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).

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] How to make www. and no www. Go to same site, for all sites?’ is closed to new replies.
Skip to toolbar