I'm looking for a regular expression for a .htaccess file where I can redirect one URL to another.
URL1: /dir/an-article-title-222
URL2: /dir/222/an-article-title
I would like URL1 to 301 redirect to URL2.
In highlevel language, I think I want to tell .htaccess to:
- Take the digits after the last dash (-)
- Put those digits before the article name with a trailing slash, i.e. 222/
- Remove the last dash and digits from the article name
Any thoughts, suggestions, code are welcome!