• Just migrated my site to a new host and installed multisite. Everything migrated over just fine and seems to be working correctly and all the pages have the same address, so relative links work.

    However, a problem has now arisen with old links in the content that included a ‘www’. Even though

    https://mysite.com/sub-page

    exists and is fully functional, any link that goes to

    https://www.mysite.com/sub-page

    doesn’t work and redirects back to the homepage. I know the problem could probably be fixed in my htaccess file, but I’m not sure how it would work with the existing WordPress multisite rules.

    Here is my existing htaccess file:

    # Use PHP5 Single php.ini as default
    AddHandler application/x-httpd-php5s .php
    
    # BEGIN WordPress
    RewriteEngine On
    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).*) $1 [L]
    RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    # END WordPress

    Any body have any ideas? Any help provided would be much appreciated. Thanks!

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

    (@ipstenu)

    ?????? Advisor and Activist

    Above all your WP rules, you’d do this to force www:

    RewriteEngine On
    #non-www to www
    RewriteCond %{HTTP_HOST} ^yourdomain.com
    RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]

    So flip it around:

    RewriteEngine On
    #www to non-www
    RewriteCond %{HTTP_HOST} !^yourdomain.com
    RewriteRule (.*) https://yourdomain.com/$1 [R=301,L]
    Thread Starter B1gJ4k3

    (@b1gj4k3)

    Yes, I actually did that right after I posted and it resulted in a redirect loop. It might also help to note my wp-config settings:

    /* Multisite */
    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', 'mysite.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    and that my siteurl and home are both set in my database (after significant tinkering) as:

    https://mysite.com/

    Thread Starter B1gJ4k3

    (@b1gj4k3)

    OK. This is getting ridiculous. I wiped out my WordPress installation, reinstalled completely and enabled multisite first thing, this time using

    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', 'www.mysite.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    (with a www)

    and htaccess is this:

    # BEGIN WordPress
    RewriteEngine On
    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]
    # END WordPress

    I have imported no content, no theme, no plugins. No nothing.

    I created a page with the address

    https://www.mysite.com/sample-page

    Tried to navigate to

    https://mysite.com/sample-page

    Page not found….REALLY!!!!????

    WTF is going on here!!!???

    Disabling mutlisite (by removing the text in wp-config and reverting to the default htaccess) and everything works fine.

    I’m ready to lose it…

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Check with your host to see if AllowOverride is set to ‘All’ in your httpd.conf

    Thread Starter B1gJ4k3

    (@b1gj4k3)

    They (BlueHost) said that it is. I also tried to enable it in in .htaccess by adding AllowOverride All and received an Internal Service error…

    FYI – on your new install, it looks like you configured it for ‘www.mysite.com’ that is why https://mysite.com/sample-page is not found. https://www.mysite.com/sample-page should work or add redirects in your .htaccess file.

    IMO, you need to choose between mysite.com and https://www.mysite.com as your main hostname. Then configure redirection in WP or htaccess. I think the htacess redirect that Ipstenu gave is the right way to go. There must be a bug in the config since it loops, but I bet tweaking it will get it working.

    You could try this (on your original install):

    RewriteEngine On
    #www to non-www
    RewriteCond %{HTTP_HOST} ^www.yourdomain.com
    RewriteRule (.*) https://yourdomain.com/$1 [R=301,L]

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I also tried to enable it in in .htaccess by adding AllowOverride

    Don’t do that ?? Won’t work.

    Honestly, if this is happening on a clean install, it’s LIKELY to be a server issue or a DNS one (probably server). Bluehost has a WordPress guru, though. Ask if they can ask him? (He’s a great guy, we’ve had lunch)

    (Personally I’d just use non-www since it works way better in the long run)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Installed multisite, now links with "www" in them don't work’ is closed to new replies.