mod_rewrite to make a short URL
-
27-09-2019 - |
Question
I have a url like:
http://skepticalgamer.com/category/slam-the-controller
I'd like to strip out "category" from the URL. So I'd want:
http://skepticalgamer.com/slam-the-controller
to act as if it were the original URL above. Is that something that can be done with mod_rewrite?
Solution
Removing the category base is easily done with Wordpress Plugins » WP No Category Base, making changes in .htaccess unnecessary. The plugin doesn't permanently change URLs in the database, so if you disable the plugin, you get your category base back with no 404s for posts.
OTHER TIPS
Yes, you could do this with mod_rewrite by doing something like this:
RewriteRule ^slam-the-controller$ category/slam-the-controller
This will take the URL:
http://skepticalgamer.com/slam-the-controller
and rewrite it to:
http://skepticalgamer.com/category/slam-the-controller
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow