I was trying to work out how to remove /category/ from my category URLs and I just couldn’t seem to remove it. For example mydomain.com/category/wordpress. I just wanted to be mydomain.com/wordpress , but I found out a quick trick to achieve this.
To get rid of category you set your permalinks to /%category%/%postname%/ and then set the Category Base to period/dot.
*If you leave the category base blank it will display the wordpress default category.*
- Go to Setting > Permalinks
- Select Custom Structure
- Add /%category%/%postname%/ after your domain
- Change Category Base to period/dot.
- Go to Yoast SEO
- Select advanced
- Click on the tab permalinks at the top
- Check Strip the category base (usually /category/) from the category URL.
To remove the category base manually in the .htaccess file just add this line of code.
RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]
This plugin also removes the category base and seems to be very popular as well. I would recommend this method the least because too many plugins will slow your website down and require you to keep more plugins up to date. https://wordpress.org/plugins/remove-category-url/
All four methods above will work for removing the category slug from your URLs. Although I would recommend choosing the method that is going to use less code in your case.