Changing URL from /%postname%/%post_id to /%category%/%postname%/%post_id%

I want to add categories to my URL structure. I’m sure this has been covered and I found many resources online to create the redirect code in .htaccess, but when I enter the code it doesn’t work. Running an Apache server.

Essentially, I want to go from

https://example.com/this-is-a-post/1111

to example/posts-category/this-is-a-post/1111

I added the following to my .htaccess:

RedirectMatch 301 ^/([^/]+)/(d+)/$ https://example.com/$1

But I still get 404s when accessing links from outside sources (Google, Reddit etc)

Read more here:: Changing URL from /%postname%/%post_id to /%category%/%postname%/%post_id%

Leave a Reply

Your email address will not be published. Required fields are marked *