How To Remove The /blog/ slug From The Permalinks(URL) in WordPress Multisite Installation Without A Plugin

What is a blog slug? If you have no clue, this post isn’t for you and if you want to know what it is, it is an ugly looking additional “/blog/” in the permalinks(URLs) in your website that comes free with the multisite feature in WordPress. Why ugly? Because it comes uninvited, it’s there and most probably you don’t want it.

How do you remove the additional “blog” in the URL of your posts? Simple, install some plugin which does it for you? That is what I thought; however, before doing so, I just took a careful look at the wp_options table. BAM! There it was. After spending about 30 minutes with settings and checking the data in this table, I have figured out a way to solve the blog slug problem without the need for a plugin. Nope, no need to change a bit of code. You don’t even need to execute any queries. The query and the table values are shown just to indicate what your action does to the database values. It’s a simple process; only step 2 and 3 need your action, you can skip the rest!

Just read on and try it out on your blog. I have also added the explanation(a little that I know). Beware, I haven’t read more than 10 lines of PHP code, so I don’t know what happens in the code but I’m 100% sure on what the end result will be.

EDIT: Mladen put all whys and hows to rest in this comment. Three cheers to the awesome commenter!

Steps to remove blog slug from post links:

  1. Here, I’m assuming that you have your permalinks as /%postname%/ Go to your blog and click on any post. You will notice the blog slug. This is because of the following to two records in wp_options table.
  2. option_id blog_id option_name option_value autoload
    1234 0 permalink_structure /blog/%postname%/ yes
    5678 0 rewrite_rules :77:{s:52:”blog/category/(.+?)/feed/(feed|rdf|rss yes

    Query – SELECT * FROM ‘wp_options’ WHERE ‘option_name’ = ‘permalink_structure’ OR ‘option_name’ = ‘rewrite_rules’

  3. Now, update the Permalink Structure.
    Go to Network Admin » Sites » Move cursor over the main site name(/) » Edit » Settings » Scroll down to Permalink Structure and update it to /%postname%/ and click on Save at the bottom of the page.

    Go to your blog and click on any post, you will notice a 404 – page not found error. This is because the above step only updates permalinks(wp_options.permalink_structure) and the records look like this:

    option_id blog_id option_name option_value autoload
    1234 0 permalink_structure %postname%/ yes
    5678 0 rewrite_rules :77:{s:52:”blog/category/(.+?)/feed/(feed|rdf|rss yes
  4. Update rewrite rules.
    Go to Site » move cursor on main site name(/) » Dashboard » Settings » Permalink. Notice Custom Structure. You will see that blog/ is outside the textbox and %postname%/ appears in the textbox. Do not edit or save anything on this page. Now, the data in the table looks like:

    option_id blog_id option_name option_value autoload
    1234 0 permalink_structure %postname%/ yes
    5678 0 rewrite_rules :77:{s:47:”category/(.+?)/feed/(feed|rdf|rss yes

    What happens is when you visit this page, rewrite_rules gets changed automatically. May be it has something to do with autoload column, I don’t know!

    A few things I noticed:

    • The value updated in step 2, goes to database as is and just to permalink_structure record.
    • Any value updated in step 3, updates both rows mentioned above.
    • WordPress takes the value in the database, removes the “/blog/” substring from it and shows the remaining in the textbox in step 3. The “blog/” shown outside the textbox is kinda fooling you. :P
    • WordPress adds “/blog/” to any value in the textbox updated from step 3 and updates both records in the database.
    • That is the reason, you shouldn’t update the permalinks from the page in step 3; it will automatically get “/blog/” add to the front of it and we will be back to square one.
  5. Visit the blog and click on any post. You should see the post and the permalink(URL) shouldn’t have the “blog slug”. If you still see it or if you are getting 404 error, you have screwed up something. Don’t blame me.
    Antonio left a tip on how to solve the 404s in his comment below. Take a look if need be.
  6. Leave a comment on this blog saying how useful it was or how stupid I really am. If I take a look at the code someday, I will be sure to let you know how exactly it works. If you do know already, what are you waiting for, leave a comment.

Oh, I also noticed that WordPress auto corrects the permalinks(URLs) even if you enter it wrong. For e.g. if your blog post is “”,, WordPress will take you to the right page even if you enter “”!!! It could be that, WordPress uses RegEx or some matching algorithm that compares from right to left and if it finds a match, it will take you to the page even if there are “/.*/” left on the left. Just a guess! Any idea? Check this for more info – How does WordPress handle permalinks?

80 thoughts on “How To Remove The /blog/ slug From The Permalinks(URL) in WordPress Multisite Installation Without A Plugin”

  1. Great workaround! It’s the only one I found that _actually_ works.

    Thanks so much for sharing!

    All the best,

    1. I’m glad that you found this useful and also thankful to you for bringing the broken math spam plugin to my notice. I appreciate it.

    1. Oh, I don’t know. I couldn’t test it. However, IMO, an update should not affect my settings, but you never know. Did it fail for you on an update?

  2. I didn’t try… :) … I already have the last version installed, but the next version 3.2.2 it’s coming soon ;)

    If anyone willing to test it on WP 3.2 and upgrade to 3.2.1… please let me know how it goes…

    1. Thanks. This saved me a huge amount of work. Usually I prefer the sub-domain network option, but this time, I needed the sub-directory multi site for a project. After migrating an existing single site to a new server and wanting to expand it to multisite, I was able to get a sub-directory install, but got stuck with the /blog/ slug.

      Wish there was something a little more stable. I assume an accidental save on dashboard > settings > permalink would undo this work around and put back the /blog/. By the way, your trick worked in WP 3.3.

  3. I’ve tried following the instructions here but have not succeeded. I am using a single-site WordPress install version 3.2.1. I have a custom permalink structure of


    “blog” does not appear in the mentioned database entries (I’ve checked using phpadmin). And, at the moment, I’m not getting 404-errors (I was earlier).

    What I’m not getting is the blog/ outside of the text box when I go back to the permalink settings page as mentioned in Step 3. What should I do?

    I currently have permalinks like: – a non-wordpress index.htm page (site home page) – wordpress blog main (home) page – wordpress category archive – wordpress tag archive – wordpress post

    What I’m trying to do is remove “blog/” from the last 3 of those to make: – wordpress category archive – wordpress tag archive – wordpress post

    Any guidance would be much appreciated.


    1. You are not using multisite installation, but a normal install – just like this website you are on. You have installed wordpress in blog directory and hence the url structure. I’d suggest not to do what you are trying to do. It looks difficult to achieve as well.
      Using mod rewrites, redirect all urls with /blog/ to urls without /blog/ and then using rewrite rules at the root directory to redirect the urls with /blog/ but with P (proxy) tag. This should send all* to* and when request comes to*, correct page will be served as the server uses pages at* without changing the url.
      I haven’t tried and am not sure if this will work and I also don’t know if this affect your seo.

  4. Thanks for posting this. I was having a lot of trouble getting the permalinks to work properly on a multi-site I’m building and your article got me back on tracks.


  5. Thanks for figuring this out an sharing it with the world. It’s insane that there is not a more intuitive way to get this done. I understand that the developers are trying to save us from ourselves in case we name a category and a sub-site the same thing, but there should be a better option in the site setup with an explanation to fix this.

    Thanks again!

    1. I agree that this should have been simpler and an options under Settings would have made everyone’s life easier. Looking at the issue, I don’t think it would be difficult for the developers to fix it.
      Thank you for your encouraging words. :-)

  6. YES! At my first try I really thought you’re stupid ;-) But in the end I was the stupid one, because I could not believe that I must not re-save the permalinks page.
    But everything is fine – and thanks for your post!!
    Cheers, Anita

  7. Lobo, many thanks for the tips.

    I just tried this on WordPress 3.2.1 with good success.

    I’m not particularly familiar with interacting with databases via query strings, so just used my host’s phpMyAdmin to browse to the correct table and row and edit the appropriate text in Step 1.

    In Step 2, I wish that Network Admin were a bit more obvious to get to and I also somehow didn’t immediately realize that ‘Settings’ would be under a tab on the page, rather than a subcategory in the left navbar, but once found, that went well.

    Regarding Step 3, I do find it particularly irritating that I am never again to use this admin page ever again. This is, of course, WordPress’ fault and not yours.

    I do appreciate the fact that you spell out what changes we ought to be seeing reflected in the database with each step, but this initially made me think that there were more steps editing the database than there really were.

    Also, in Step 1, I saw so many “blog/” entries in rewrite_rules that I was uncertain as to whether I was to edit them all out manually or not. Thankfully, I chose to only edit the single instance that you cite and the site updated the rest automatically after Step 2.

    Thanks again for the help.

    1. I think I wasn’t clear enough, if you carefully read the steps you don’t need to write/execute any database queries. The data shown in step 1 is directly from my database table and I just provided the query if anyone needed it. Step 1 is actually read only. Also the database values shown might actually be different if you have a different permalink structure.

      I wish there was a simpler way to do it. I’m glad you were able to get it working.

      1. I updated the post to mention that three is no need to execute any queries and also mentioned that only step 2 and 3 are necessary… Thank you Nate.

  8. I just loved your first paragraph :D.

    Now, why this works?
    Rewrite rules that are used to resolve something like:
    are not generated every time WP runs (performance issues), but are fetched from the database (the autoload field tells WP which options to load every time it runs – those that are often needed; it doesn’t have anything to do with the step 3).

    Step 2 (wp-admin/network/site-settings.php?id=1) updates permalink structure (which is then used to generate links for posts), but does not update rewrite rules (that is why after step 2 it doesn’t work). Unexpected, but that’s how it is.

    Step 3. When you visit permalink settings page (wp-admin/options-permalink.php), rewrite rules are flushed. There is a line:
    That is executed when you load that page, and it clears/regenerates rewrite rules (using permalink structure from the database, that is the one from the step 2, no /blog there). Why it only works if you don’t save the settings? If you save, during the procedure WP will check if those are rules for the main site in multisite, and if they are (and it’s not a subdomain install), it will spice them with /blog in the front. That part is hardcoded into options-permalink.php (I guess a plugin could use pre_update_option_permalink_structure filter to undo this, but it’s all ugly as you sad).

    So this will work as long as procedure for regenerating rules stays like this (inconsistent). Plugins that flush rewrite rules should not break this (assuming that /blog is forced only in the options-permalink.php procedure), but that should be tested.
    Hope this helps.

  9. I’ve used a wordpress template as a website. I don’t really need permalink. But I have this ugly message “Permanent link to this post (42 words, 4 images, estimated 10 secs reading time)” How do I turn permalink off? Or make it invisible. It’s just a website without any archive. Much appreciate your help. Anna.

    1. I run WordPress too, but haven’t encountered this issue. Please look at the settings page to find if this is enabled from any setting. Also, make sure you aren’t using any plugin that is intentionally displaying this information. Please go to the forums at WordPress support for better visibility.

  10. My Sites > Network Admin > Sites and click on the first one, it’s usually just slash / and you will end up on Edit Site:

    Next step is to click on Settings go down to Permalink Structure and remove blog from /%postname%/ save it and that’s it.

    Go back to you main site and save your permalinks once again, to generate new .htaccess.

    In wp-config.php my multisite setup looks like this:

    /* WP Multisite */
    define('MULTISITE', true);
    define('WP_ALLOW_MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    $base = '/';
    define('DOMAIN_CURRENT_SITE', '');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    just in case anyone’s wondering, no special settings whatsoever.

    And please NOTE never ever edit WordPress Core files, not only that you can break your WP install, but changes will be overridden in next WordPress update.


  11. I tried this and was getting a 404 error for individual blog posts. I then ran this flushed the permalink rules using the $wp_rewrite->flush_rules() method. I stuck this block of code in my functions.php file.

    NOTE: I ran it once then commented it out; it is bad practice to always execute this function.

    1. Thanks Antonio for the tip. I corrected you comment and deleted the other one. Hope it’s okay. :-)
      I have mentioned this in the post itself. Thanks.

    1. Hi Nikhil,
      I’m not an expert in this area, if you really need help please try WordPress forums or StackExchange fo wordpress. Sorry!

  12. I’ve only read/executed steps two and three but I can confirm that the steps work as expected.

    I was able to change the “blog” slug or simply remove it.

    Thanks for documenting your research and findings.

    1. Anything that works for you. A plugin, as mentioned in that post, better as it gets constant updates and works with any version. Thanks for sharing…

  13. Interesting spin on this. I’m working with breadcrumbs for a client on their complex multisite website. They didn’t want the breadcrumbs to read “blog” which has led me here. I successfully changed the permalink from “/blog/” to “/wow/” which works for our site – but there was no change in the breadcrumbs.

    So frustrating! If anyone has had to deal with this before let me know if you can help.

    1. Do you get “blog” in the actual breadcrumb trail (e.g. home>blog>category>title), in the link (href attribute of the anchor tag), or both? I tested this with Breadcrumb NavXT plugin and there was no extra “blog” added. It’s probably an issue with the code generating breadcrumbs (or with some breadcrumb settings). Do you know which plugin/theme is generating breadcrumbs, or is it some custom written code?

  14. THANK YOU !!! amazing, strange and 100% working, useful fix for a weird problem i was having after migrating multisite to a IIS 7.5 server. I think the server guy had to add loads of hacks and one of them redirected everything to / so pages that had be automatically been placed in /blog/ were getting a 404 error. this fixed it so everything is a .. ( thanks again !! )

  15. I found another simpler solution at forum that works OK for me:

    1. At blog site set Settings -> Permalinks -> Common Settings -> Default (Select default only and don’t touch any thing, If you need to change category base, change it in Network Admin)

    2. At Network Admin -> Sites -> (root site) -> settings ->Permalink Structure -> /%category%/%post_id%
    (or whatever you need)

    That it will remove /blog slug

    1. This solution rocks! It’s so easy when you know how! Why doesn’t wordpress make this more intuitive? Thanks for sharing – now I have pretty permalinks on my multisite not ugly permalinks. Thanks.

  16. Thanks for this method! :)

    I went through the whole 404 error thing and did the replace/reload step. Worked like a charm. And I dare not touch the permalink bit anymore in case the /blog slug appears again.

  17. Wow… I have no idea how you stumbled upon this but I couldn’t believe it worked… I feel like I just hacked WordPress or performed some kind of witch craft… haha thanks!

  18. Thanks a ton Buddy !!.. For such a fabulous working step by step solution. I’m grateful to you. Live Long & Prosper :-)

  19. I know this post is kind of old but it still applies. I’ve used this odd trick to fix permalink issues on several different sites. I don’t know what kind of magic happens when you visit that permalinks page in the admin panel but I’m glad it works. I spent 2 days trying to get permalinks to work with custom post types and taxonomies and then I remembered reading this a while back, clicked on permalinks in the admin panel and bam everything works. THANKS!

  20. It worked. Still it is a weakness in the multi-system setup with sub-directory structure. What if someone else starts a new site with the category name used in the first site under domain name

  21. Everything is very open with a precise clarification of the issues.
    It was definitely informative. Your site is extremely helpful.
    Thanks for sharing!

  22. This worked perfectly after my third attempt (The first couple of times i hit ‘save’ on step 3) So it serves me right for reading your information too quickely !

  23. Everything said was very reasonable. But, what about this?
    what if you added a little content? I am not suggesting your information is not good,
    but suppose you added a title that grabbed folk’s attention?

    I mean How To Remove The /blog/ slug From The Permalinks(URL) in WordPress Multisite Installation Without A
    Pluginlearn(n*share(n,learn(n+1))) is a little vanilla.

    You might peek at Yahoo’s home page and watch how they
    write post titles to get people to open the links.

    You might try adding a video or a picture or two to get people excited about what you’ve got to
    say. In my opinion, it would bring your posts a little livelier.

  24. Hi,

    Thanx for the post. But I need to do something that is the oposit of your post title :P
    What I want is to add the /blog in the subsiste blog post permalinks, I mean: <- OK <- NOT WORK

    The question is. Is this possible? becasue if I do that change in the subsite permalink, I try to use only /%postname%/ in the permalink but this makes the posts always shows the front-page.php template and not single.php template.

    Also found the /blog is reserved to the main site :( and can´t find a guide or tutorial to explain if is possible to do what I want using the htaccess or some rewrite code in the funtions.php

    Any idea? thanx for any help :)

  25. When I originally commented I clicked the “Notify me when new comments are added” checkbox
    and now each time a comment is added I get several emails with the same comment.
    Is there any way you can remove people from that service?

    1. Hi, I apologize for the inconvenience. I use a plugin to enable that option and it has behaved properly in all cases. I’m not sure what happened. In the email you get, there is a manage subscription link. You may use it to manage your subscriptions. You can also do it from link. Your email is not on the list for any subscription currently. Thanks for letting me know.

  26. Thank you very much! This is the best solution ever! I tried everything, plugins, editings.. but THIS is what gives me the result I want, and with so much less effort than the other options :D
    Thank you again!

Leave a Reply

Your email address will not be published. Required fields are marked *

Human? Enter the correct answer below : * Time limit is exhausted. Please reload the CAPTCHA.

Notify me of followup comments via e-mail. You can also subscribe without commenting.