How to Force Multi Site to Use Subdirectories

One of the most common issues to afflict most web developers who try to enable WordPress Multi Site is WordPress’s insistence that subdirectory blogs cannot be setup. The message WordPress throws up to show its dominance over afflicted web developers is:

Because your install is not new, the sites in your WordPress network must use sub-domains. The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.

And the first thing afflicted web developers do is… they scream at their computers “What the f**k is that supposed to mean?”

Seriously, what is it supposed to mean?

The next thing they do is Google for answers. I know this because I tried both strategies before I bit the bullet and re-installed a very large WordPress installation. Some of my search terms were:

  • Can’t enable multi site subdomains
  • WordPress won’t allow subdomains
  • How do I enable subdomains not subdirectories in WordPress
  • How do I force subdomain use in WordPress MS
  • WordPress subdomain subdirectory installation problem multi site

If you followed the same path as me and eventually, after re-installing WordPress, returned to the Multi Site activation screen you would know that re-installation, contrary to what is indicated by WordPress’s message, is not the solution. No, what WordPress is trying to say in a convoluted way is not that the WordPress installation is too old for Multi Site to be enabled for subdirectories but something else. Here is a translation of its message:

The URLs of some of your blog posts might conflict with the URLs of the subdirectory sites you create when Multi Ste is enabled therefore it is advised that you do not enable subdirectory sites.

Why the hell the WordPress development team use such cryptic error messages that require translation is, well, a Universal mystery.

In short, if a WordPress site is more than 30 days old, WordPress will try to prevent its multi-site conversion from using subdirectory addon sites.

There is a workaround to enforced subdomain addon site installations. Yes, we can fight back and force WordPress to allow subdirectory sites.

Force WordPress to Allow Subdirectory Blogs

During the activation of Multi Site a few lines of code need to be added to wp-confg.php. One of those lines states:

That line tells WordPress to use subdomain addon sites.

Change it to

and you will now be able to create subdirectory sites.

Currently, WordPress messes around with subdirectory site URLs. It adds a /blog/ slug after the TLD. For example, if a subdirectory site is created with the name “apple” such that its URL should be

then WordPress renames it

Now that does not look very professional. In fact, it looks pretty damn ugly. Thankfully, the “blog” slug can be removed. A plugin is available from ThinkingWordPress (direct link) which does just that – it removes the ugly “blog” slug.

There are Two Snags with All This

Forcing WordPress to allow subdirectory addon sites on old WordPress installations has a price:

  1. Subdirectory sites that resemble existent post, page, tag, category or directory names must not be created,
  2. Some subdirectory sites will not display as they should because of conflicts with the main site’s permalink URL structure.

The solution for the first issue is simple:

  • Do not create addon sites with names the same as existent WordPress slugs.

The second problem is characterized by any of

  • Subdirectory sites do not display when viewed
  • Subdirectory sites display but their themes are corrupt (missing CSS files)
  • Subdirectory site backend admin panels redirect to the main site’s admin panel

Other symptoms will probably exist also.

The solution is simple and involves changing the Multi Site’s URL rewrite rules.

Edit your .htaccess file and replace

With

And that is all there is to forcing WordPress to allow subdirectory addon site installations when Multi Site is enabled.

The Blog Slug

WordPress will insist on inserting a blog slug into the sub-directory URLs such that my-blog.tld/site-one/my-post will look like my-blog.tld/blog/site-one/my-post. This can be removed with the Remove Blog Slug plugin from here.

Comments

    • says

      Save your permalinks again.

      Also, go to the network dashboard and follow the network setup instructions with regard to the htaccess rewrites that need to be in place.

  1. jacksonpon says

    there is error 500.. after i replace the contents in the .htaccess file. After changing back to the old contents of the .htaccess, i was able to return to my website.. any idea where went wrong?

Leave a Reply