2
votes

I'm unable to do a 301 redirect rule for a website I'm redoing. This is what the redirection must do:

Original:

domain.com/blog/4-blog/49-name-of-post

New:

domain.com/name-of-post/

The 49- depends on post, meaning is different in all posts, but always 2 digits followed by -.

So 2 directories now disappear, also 3 first characters of the page name and the final slash.

Any ideas to accomplish that without doing all redirects by hand?

1

1 Answers

1
votes

You can use this rule in root .htaccess:

RedirectMatch 301 ^/blog/[^/]+/[0-9]+-([^/]+)$ /$1/