Post Pic

How to: Remove /category/ from your WordPress url

Ever wanted to be able to finally remove the useless /category/ from your WordPress categories permalinks? If yes, read on and get ready to hack your .htaccess file!

By default, WordPress category permalinks are displayed that way:

http://www.catswhocode.com/blog/category/wordpress

As you can see, the category in the url is pretty useless. Here's how to remove it:

First backup your .htaccess file. Then, open it and append the following line:

RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

Once saved, your categories pages will be displayed like this:

http://www.catswhocode.com/blog/wordpress

Better, isn't it?

19 Responses

Aug 09 2011 12:46

This can be done as:

RewriteRule ^category/(.+)$ /$1 [R=301,L]

This is without ‘http://www.yourblog.com’ – useful if you are switching between local/staging/production environments. Although it doesn’t work on some server setups.

Sep 02 2011 20:23

It doesn’t work with subcategories. I have custom subcat pages on my theme. When i use this Rewrite Rule my subcats pages goes to 404.php :(

Sep 13 2011 13:51

like @Daniel said doesn’t work on subcategories.
so what we can do?
thanks.

Sep 16 2011 06:43

Just add the plugin WP No Category Base and everything will be ok!
Don’t need to mess with the .htaccess file!

Oct 05 2011 05:19

Yes, Tiago that’s was the best option. But out of curiosity where is that hard coded in WordPress. I always prefer to modify the wp files than to use the plug-ins.

Had a quick look in to wp-includes/link-template.php

Will go through again once got some extra time.

Nov 13 2011 18:13

As of WordPress 3.1.2, but I suppose even for previous versions, this is article is a no no from the start down to the previous comment.

First, *appending* the rewrite rule will never work since the previous ones as they are written will not allow to be executed, ever.

Second, the url structure example.com/ is assumed here to work out of the box, but simple it does not.

Third, @nSathees, the editing of the WordPress core files is a no no and no one will advise you to do so. Plugin, or at least the well programmed ones, are the way to go because they ensure optimal management and consistency.

Fourth, there is no way to do the /category/ removal with an .htaccess solution. A plugin is required.

Nov 15 2011 20:40

This solution break the pagination. Doesn’t work.

Jan 02 2012 18:46

Hey every, after reading through these comments I decided to go down the route of installing a plugin after my attempts with the 301 redirect turned out to be useless.

WP No Category Base – WPML compatible – this is the plugin I’ve installed to remove the /category/ slug from my urls. If you’d like, head over to my site and check out the plugin live.

To avoid this looking like spam I’m assuring you the plugin will work – there’s no need unless you want to double check to head over to my blog.

Jan 21 2012 16:45

The wordpress plugin that Jesse recommended worked for me! WP No Category Base – WPML compatible

Thanks for the share!

Jan 22 2012 14:19

WP No Category Base plugin is a great replacement for the .htaccess trick. Thanks.

Feb 03 2012 19:01

Thanks for suggesting WP No Category Base – WPML. It did just the trick on my WP Multi-site install. Make sure you Network Activate it when you do install it!

Feb 10 2012 14:43

I had problems with the Top Level Categories plugin, it broke my category links, so I switched to the No Category Base plugin and this works much better

Feb 14 2012 03:50

I don’t like to install a plugin for everything also. I just wish there is a good solution for this annoying thing, I really do not see why WordPress keeps pushing this “feature”.

Mar 03 2012 08:51

Easiest Solution here is a plugin to remove category base

http://wordpress.org/extend/plugins/wp-no-category-base/

Enjoy!

Mar 08 2012 06:45

You guys weren’t kidding about the WP no category base plugin. Installing and activating it were a snap. And it works!

Mar 18 2012 08:27

thanks for sharing a great trick but unfortunately it does not work :(

Apr 03 2012 04:16

Unfortunately it’s not working for my site.:(

Apr 06 2012 13:54

I tried this method and got a little success but unfortunately found a bug when try to open sub categories it gives 404 Error. Any suggestion.

Apr 15 2012 07:48

You can also do this easily with the plugin “WordPress SEO” by Yoast (under Permalinks section of that plugin).

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required

WP Theme generator

Sponsored Likebox