How to remove /blog from URL in Word Press- No Coding Required

Blog Slug Removed

Most of the early stage bloggers or websites that's been powered by word press want /blog/ slug removed from their URL. For this a lots of useful plugin can be found. But there is a direct very simple risk-free, coding-free way available by which we can remove /blog/ slug from URLs of our website or blog.
 


Let’s take an example- Say if your website name is example.com, the URL will be http://www.example.com OR http://example.com depending upon what exactly you have chosen.
 

Say you have written a post named (H1) Men On mars, then one probable URL would be http://www.example.com/blog/men-on-mars. The extra /blog/ slug not only makes URL a bit lengthy but also ugly in sense or other.
 

Now guys at Word Press have developed a very easy way to get rid of /blog/ slug in multisite installation. Here is the step wise step solution on of it.

How to remove /blog/ from Word Press URL:

We are presuming that you have your permalinks as /%postname%/



Step 1– Go to your blog and click on any post. You will notice the blog slug.

http://www.example.com/blog/men-on-mars/

Step 2– 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.

Step 3– Go to your blog and click on any post, you will notice a 404 – page not found error. Don’t Panic! This is because the above step only updates permalinks(wp_options.permalink_structure).



Step 4– Now What we have to do is to 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.

And We are Done !!

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

WordPress auto corrects the permalinks(URLs) even if it is entered incorrectly. For example; WordPress will land you in example.com/some-post even if you enter example.com/idontexist/some-post or even example.com/some



Now visit the blog/website 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 then the approach you will have to opt in a bit technical- you will have to flush the permalink rules $wp_rewrite->flush_rules() method in your functions.php file. (run just once.)