You may be wondering that WordPress allows us to remove category slug from URL? By default, WordPress adds a category base of /category/ to the URLs of all category archive pages.
In SEO, we generally talk about shaping the right slug for your site page. As you may know, a URL slug is the part of a link that comes after the domain extension that indicates the link direction.
A perfect URL slug not only helps the user to understand what your page about but also to improve SEO of the page.
How to Remove Category prefix from URLs
Coming to the point, you can undoubtedly remove or change /category/ slug from your page WordPress URLs.
yourdomain.com/category/entertainment/
Can be turned into ↓
yourdomain.com/entertainment/
You heard it right, you can even change it to something different like you can replace /category/ to /info/ or whatever you wanna replace with.
yourdomain.com/category/entertainment/
Can be turned into ↓
yourdomain.com/info/entertainment/
If it’s not about SEO or whatever any reasons you want to remove or change *category* slug from URL, you need to follow one method from below 3 methods that suit you best.
1. Remove Category prefix from URLs with Permalink settings
The very first and simple method to remove /category/ base from site URLs is done within the WordPress dashboard. You just need to log in to your WordPress site and head towards Settings > Permalinks.
Next, you have to just put a dot ( . ) in the Category Base field. Once you do that WordPress considers this dot ( . ) to blank space in URLs, so ultimately it gets rid of /category/ slug in URLs.
Also, keep in mind, you can even change /category/ slugs with something else. Just put anything in the Category Base field and it will replace it with default settings. If you leave Category Base blank. the category will be displayed in your WordPress URLs.
2. Remove Category from URLs with .htaccess
If you don’t want touch permalink settings, no worry you can do this via .htaccess. To do this, you need to paste one line of code to your .htaccess file
Your .htaccess file starts with a dot because it is a hidden file. So if you don’t see it in your root folder, make sure that your file manager isn’t keeping those files hidden from view.
Once you found it, copy and paste the below code to your .htaccess file and save your changes:
RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]
Make sure you replace http://www.site.com/ to your domain name.
Next, upload it on your server’s public_html directory. You can access it using FTP client software or File Manager in your cPanel.
3. Remove Category prefix from URLs with Yoast Plugin.
If you’re using Yoast plugin then this is the easiest & safest method you’ll see. With the help of this plugin, you can remove the category prefix from the URLs instantly without adding or changing any code in core files.
To do this:
- From the WordPress dashboard, click or hover on Yoast SEO
- Click on ‘Search Appearance’
- Click on the ‘Taxonomies’ tab.
- Toggle the ‘Category URLs’ switch.
- Set to Remove to remove the categories prefix
Wrapping up:
These are some methods to remove /category/ prefix from your site URLs. Of course, there are might other methods too but those would to complicated and dangerous so keep it simple and safe.
I hope this article answers all questions regarding this topic if you having questions or suggestions on this topic feel free to let us know by leaving a comment in the comment section.