Home

Wordpress Multi-site from Sub-domain to Sub-directory

Created November 10, 2011

As many of you may know since Wordpress 3.0+ it is pretty easy to turn your single wordpress site into a multi-user or multi-wordpress site. If you are unsure of how to change from a single site to a multi-site, you can check out this article for How to enable Multi-site in Wordpress.

Okay, so the problem came when I wanted to change my wordpress install from a single site to a multi-site because I already had my main site set-up, wordpress gave me a notice saying that "Because your install is not new, the sites in your WordPress network must use sub-domains." So, basically it was telling me that I had to use subdomains, instead of subdirectories. Okay, well I went ahead and set it up that way. And after I did that, I was able to simply change my multi-site from using subdomains to using sub-directories. Here's how I did it:

After you have configured your wordpress install to be a network (multi) of sites, make the following modifications:

In your wp-config.php file change this:

    define( 'SUBDOMAIN_INSTALL', true );

to this:

    define( 'SUBDOMAIN_INSTALL', false );

And then in your .htaccess file

Change this:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

# END WordPress

to this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
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).*) $2 [L]
RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress

After you have made those changes and saved those files, your network of sites will now use sub-directories as opposed to sub-domains. YAY!

Okay, hope that can help someone out in the future ;)