You can remove the base category slug in the WordPress permalinks structure. Earlier this was done with the help of a plugin or PHP function but now you can do it from your admin area dashboard.
By default the category URL on WordPress looks something like this – yourdomain.com/category/category-name, now we have to remove the category from the permalink so that URLs should look something like this yourdomain.com/category-name/.
These steps allow you to remove the category prefix completely by modifying your site’s permanent link settings.
- Navigate to your WordPress dashboard
- Navigate to Settings -> Permalinks page
- Scroll to Custom Structure and put ‘/%category%/%postname%/’.
- Go to Category Base and type in a dot “. “
- Save your changes.
The category prefix is removed by typing the dot in the category base field. It completely removes the mandatory category base from the category permalinks, so the category name comes right after your domain name in the permalink structure.
By default, this field is left blank which represents the default prefix.
Alternatively, you may add the following rule in .htaccess file present in the root directory of your website :
RewriteRule ^category/(.+)$ https://www.yoursite.com/$1 [R=301,L]
This also removed the category base, don’t forget to replace yoursite.com with your domain. The same can be done with the help of the Yoast SEO plugin. If you are using it on your website simply navigate to Yoast SEO -> Search Appearance and open the ‘Taxonomies’ tab.
Scroll to the Category URLs, select ‘Remove the categories prefix’, and save the changes.