Reputation: 1
I have a WordPress site where all posts are in the form of:
http://example.com/category/12345-my-post-tile-is-here
where 12345
is the post_id
.
I want this to be done to the following format:
http://example.com/category/12345/my-post-tile-is-here
Is it possible using .htaccess
301 redirect or URL rewriting using regex find and replace?
I had already tried to use custom permalink structure in wordpress settings but the result is not what I looking for.
I also tried this in my .htaccess file:
redirect 301 ^(.)-(.)$ /$1/$2
but the result for http://example.com/category/12345-my-post-tile-is-here is http://example.com/category/12345/my/post/tile/is/here/
Upvotes: 0
Views: 591
Reputation: 321
Use WordPress permalink support.
You can rewrite the permalinks from WP dashboard Settings -> Permalinks
.
/%category%/%post_id%/%postname%
and savehttp://example.com/category/postid/postname
Upvotes: 2