Reputation: 501
I´m creating a new Wordpress Website based on a old one.
Both sites got an archive page but with different permalinks.
Old-Adress: old.url.com/anzeigen/anzeigen-detail/article/article-name123.html
New-Adress: new.url.com/anzeige/article-name123
Since I have 2000+ articles, I´m looking for a single redirect Rule to handle all of them at once.
I know how to do a simple redirection for a single URL but not multiple at once.
Upvotes: 0
Views: 43
Reputation: 45968
Try the following at the top of your .htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old\.example\.com [NC]
RewriteRule ^anzeigen/anzeigen-detail/article/([\w-]+)\.html$ https://new.example.com/anzeige/$1 [R=301,L]
If the old URL /anzeigen/anzeigen-detail/article/article-name123.html
does not exist at the new domain, then you don't necessarily need the preceding condition.
[\w-]
- The dynamic part (ie. article-name123
) can consist of the characters a-z
, A-Z
, 0-9
, _
(underscore) and -
(hyphen).
Test first with 302 (temporary) redirect to avoid any caching issues.
Upvotes: 2