Reputation: 9
I just finished my Wordpress website migration and I found that all my posts ids Got changed after the migration what is bad for my SEO because I use the IDs on the URLs.
Example of old URL: http://www.example.com/news/category/postname-ID.html
Example of new URL: http://www.example.com/news/category/postname.html
As you can see I’m not using the IDs anymore on the URLs since it’s not the same.
So I would like to know how to use htaccess to rewrite URLs from Example 1 to Example 2
NB: The Id is not the same it dynamic.
Thanks
Upvotes: 0
Views: 1020
Reputation: 80639
Give the following rules a try:
RewriteEngine On
RewriteRule ^(news/category/.*)\-\d+(\.html) $1$2 [R=301,L,NC]
assuming that the ID
s are numeric. This would also fail, if, for eg. your postname is something like: see-this-post-number-13.html
or This-is-year-2015.html
Upvotes: 0