1

I need to make a rewrite rule or redirect with a wildcard included in the line. Here is an example of what i have so far that works for an individual link.

Redirect 301 /actors/hey-steve-dave-454924/ http://www.mydomain.com/

I would like to have something like Redirect 301 /actors/hey-steve-dave-* , where * redirects anything with the /actors/hey-steve-dave-(any 6 numbers) to the home page.

Any ideas?

2

Use RedirectMatch:

RedirectMatch 301 ^/actors/hey-steve-dave-.*$ http://www.mydomain.com/

That's just a wildcard of anything after hey-steve-dave-, you can get more specific - this would be exactly 6 numbers and nothing else, with or without the trailing slash:

RedirectMatch 301 ^/actors/hey-steve-dave-\d{6}/?$ http://www.mydomain.com/
2
  • 1
    Small addition; RedirectMatch uses regular expressions, so the "wildcard" is .* rather than just * – fukawi2 Apr 16 '13 at 3:55
  • @fukawi2 Right, I've also added an additional example that's more exact. – Shane Madden Apr 16 '13 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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