If you only knew how many times I got this one…
When I made my multisite, it changed all the URLs on my main site from example.com/postname to example.com/blog/postname ! How do I change that!?
This is because you picked Subfolders for your network.
Now before you get into this, ranting that it’s wrong, please actually read all of https://core.trac.wordpress.org/ticket/12002 first. The initial ticket was that if you used subdomains, you were also locked into using /blog/
. We’ve obviously fixed that, but it brought up a bigger issue.
Why do we keep it? To prevent conflicts. If you use /blog/%postname%
and have a post named “humperdink” and another subsite named the same, it would cause a mess of problems. It’s one thing to search all your pages for possible conflicts (remember, your pages will still show up as example.com/pagename
), most people only have a few pages. But once you factor in the hundreds of posts, it gets really crazy. If you have an open Multisite, where anyone can register any site, you have no way to doublecheck the URLs.
So we’re making sure we don’t conflict with posts and sites, which is pretty impossible to do without a massive DB query every time you post, as well as pages and sites (less massive). I think that we should have some slug in there for those reasons.
Or as Nacin put it when he detailed out a potential roadmap for Multisite:
Dealing with URL Conflicts
Perhaps the greatest change will be addressing the issue of the main site gaining a
/blog
prefix. This is ostensibly to avoid top-level pages on the main site from clashing with sub-sites. With arbitrary domain support (via domain mapping primarily, and secondarily via secondary networks), any site with path/
can clash with any other site with the same domain but a different path. With multiple path segments (nested sites), any site with path/X/
can have pages that clash with site/X/Y/
.Ultimately, this requires two-way blacklisting. Before a site is created, it must be checked against top-level URLs of the possibly conflicting site. And, before a page is created, it must be checked against sub-sites that already exist. If an
/about/
page already exists onexample.com/
, an/about/
site cannot be created. But if anexample.com/blog/
site already exists, a/blog/
page cannot be created onexample.com
. This gets complicated quickly, and is a very strong argument for only supporting one path segment in core by default, and allowing plugins to handle these potential conflicts on their own. In most cases, simply ignoring the potential conflicts is going to be sufficient.
You see the headache? But hey, if you’re sure it won’t be a problem, you can do this yourself.
Edit the site via network admin -> sites
Click on settings and scroll till you find the permalink settings:
Remove blog and save. Done.
Now bear in mind, should you ever change permalinks on the main site, you will have to go back and do that again. This is because on the permalinks page, it’s hardcoded in:
Also some plugins will refresh permalinks and accidentally put it back in, so you need to be very careful. Someone wrote a cron job to re-write that value every hour in the DB.
Comments
One response to “Mailbag: Trash the Blog Slug”
I had a customer that was extremely upset about this and blamed us as the host for doing this to their site lol for some reason it was hard coded and couldn’t be changed in permalinks so we provided this method that worked
https://wordpress.org/plugins/remove-blog-slug/