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?

10 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.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required