Removing the base slug of a taxonomy is a tricky business in WordPress. We suggest using a plugin instead of hardcoding it in your theme.
To remove the base slug of any taxonomy:
To remove the “category” slug:
Three of the plugins above are old and not updated. To remove the default “category” base slug from the URL, we recommend using Remove Category URL. You may use WP htaccess Control to remove the base slug of your default tags and the base slugs of your custom taxonomies.