• Resolved sturvey

    (@sturvey)


    Hi. I’ve just added multisite functionality to my WP install (sub directories; WP is installed at /blogs/) and it went smoothly except now, whenever I type in example.com it redirects to http://www.example.com/blogs. No such problem when typing www.example.com. I have a non-WP index.php file in the site root which I want to keep as is.

    htaccess:

    RewriteEngine On
    RewriteBase /blogs/
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [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]

    and wp-config:

    define('WP_ALLOW_MULTISITE', true);
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', false );
    $base = '/blogs/';
    define( 'DOMAIN_CURRENT_SITE', 'www.example.com' );
    define( 'PATH_CURRENT_SITE', '/blogs/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );

    Please can somebody help resolving this. Thanks.

    [ Please do not bump, it’s not permitted here. ]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sturvey

    (@sturvey)

    I think I’ve solved the problem. I put a .htaccess file in my site root with the following code:

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

    …so it redirects non-www stuff to www.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    WP is installed at /blogs/)

    You mean you installed WP at example.com/blogs but you want to run it out of example.com?

    That’s unsupported and doesn’t work well. Right now you MUST run WP Multisite out of the folder in which it is installed.

    If you put it in example.com/blogs/ then all your URLs must start with that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Unwanted redirect when you don't use 'www' in URL’ is closed to new replies.