WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] www issue with main site in multisite (5 posts)

  1. Chantal Coolsma
    Member
    Posted 1 year ago #

    A customer of mine is running a multisite and we have an issue redirecting www to non-www. This happens:

    If you visit for example http://www.domain.com/some-page it returns the homepage http://domain.com. Not as http://domain.com/some-page.

    For sub-sites this works okay. The page is available for both www and non-www urls. http://www.domain.com/en/some-page will show http://domain.com/en/some-page.

    I found a solution to put in .htaccess, but this breaks domain mapping. What is the right way to fix this? I can't find a solution that works without breaking domain mapping.

  2. What .htaccess fix did you use?

  3. Chantal Coolsma
    Member
    Posted 1 year ago #

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

    This works on both main site and sub sites, but breaks additional domains mapped with domain mapping. They all lead to the main site homepage.

  4. Well right :)

    Your rule says "If a page is NOT domain.com, make it go to domain.com"

    Try this:

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

    It says "If a page is http://www.domain.com, make it go to domain.com"

    A subtle, but VERY important difference ;) (The real problem is the server thinks www and non-www are different things, and you can configure vhosts to send one to the other, but .htaccess works fine)

  5. Chantal Coolsma
    Member
    Posted 1 year ago #

    Thanks! Domain mapping also works.

Topic Closed

This topic has been closed to new replies.

About this Topic