Currently I added custom structure for posts premalinks /post/%post_id%
through permalinks settings in Admin.
Since I need to rewrite permalinks for categories, tags and author pages as follow:
Categories
Current /post/category/category_name
to /category_name
Tags
Current /post/tag/tag_name
to tag/tag_name
Author
Current /post/author/author_username
to /author/author_username
I tried to create custom RewriteRule in .htaccess, which didn`t work at all:
RewriteRule ^/([^/]*)$ ./post/category/$1 [L]
RewriteRule ^/tag/([^/]*)$ ./post/tag/$1 [L]
RewriteRule ^/author/([^/]*)$ ./post/auhtor/$1 [L]
Any help with .htaccess rules coding to achieve such permalinks is much appreciated.
This way you can achieve following url formats:
Categories
Tags
Author
I didn't test with WordPress, but with http://htaccess.mwl.be/
You were pretty close:
I didn't test with WordPress, but with http://htaccess.mwl.be/
If you are not doing a pretty high-performance Project, i would strongly suggest noch to mess around with the Wordpress standard .htaccess and instead use Wordpress internal functions to accomplish the same task. Despite a cleaner Project this would also make your solution Webserver agnostic (who knows if you want to switch to NGINX or something else in the future).
Wordpress main function that should help you quite a bit is add_rewrite_rule. As an example your category link could look like that:
Though you should bear in mind, that the regex should have exceptions for other 'top-level' objects.
An important note from the wordpress docs: After adding new rules you have to flush the rules table: From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.
There is also a plugin called Rewrite available. As it has not been updated for a long time, i would not suggest using it in Production, but its code could server as a source of inspiration.