1

I have a lot of URLs like this: www.mywebsite.com/blog/item/1021-le-foreste.html that becomes, after SEF changes, like this: www.mywebsite.com/blog/le-foreste.html How can I write an .htaccess rule that say something like: where you find an URL with "item" word and ID number redirect to the same URL without "item" word and ID number, please? Thanks a lot.

1 Answer 1

1

Add this line to the very beginning of your .htaccess file:

RedirectMatch 301 /blog/item/(\d+)-(.*) /blog/$2

Explanation:

  • This part (\d+) matches any number immediately after /blog/item/
  • This part (.*) matches anything after the first dash.
  • $2 represents what (.*) matches, which is anything after the number and the hyphen (note that $1 will be the number, which is 1021 in the case of your example above)
1
  • 1
    It works, thank you. Apr 27, 2017 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.