This should work for you:
RewriteEngine On
RewriteRule ^(.*)/([0-9]+)-(.*).html$ /article/$3-$2/ [R=301,L]
It should change domain.com/category/123-title-of-article.html
to domain.com/article/title-of-article-123/
Question
I need help redirecting my old URL to a new URL.
They URLS are structured as required.
My OLD URL is something like domain.com/category/123-title-of-article.html
, where category
is the category name and 123
is the Post ID
The NEW URLs are (and this is how I want them to redirect): domain.com/article/title-of-article-123/
, where article
will remain as it is in all URLS, and the post ID will go to end of the URL
How I can achieve this?
La solution
This should work for you:
RewriteEngine On
RewriteRule ^(.*)/([0-9]+)-(.*).html$ /article/$3-$2/ [R=301,L]
It should change domain.com/category/123-title-of-article.html
to domain.com/article/title-of-article-123/
Autres conseils
RewriteEngine On
RewriteRule ^/?category/(\d+)-(.+)\.html$ /article/$2-$1/ [L,R=301]
Also, you already have the rewrite rules to handle your new URL, right?