1
votes
apache - RedirectMatch 301 issue - Stack Overflow
Asked
Active 9 years ago
Viewed 960 times
1

I have an issue in my RedirectMatch 301 rule.

I want to redirect all urls like theses:

http://www.toto.com/lang/fr/tutu/salut-les-gens
http://www.toto.com/lang/fr/tutu/trop-bien
http://www.toto.com/lang/fr/tutu/gg-a-toi

to:

http://www.toto.com/blog/tutu/salut-les-gens
http://www.toto.com/blog/tutu/trop-bien
http://www.toto.com/blog/tutu/gg-a-toi

I have set this rules:

RedirectMatch 301 ^/lang/fr/tutu/.* /blog/tutu/$1

but it's redirections to http://www.toto.com/blog/tutu and not http://www.toto.com/blog/tutu/salut-les-gens

Thanks !

1
  • 1
    here you find clear explained instruction how to "accept" the answers. Additionally starting with 15 reputation point you have right to vote any helpful answers or questions which you find. You have right to vote about 30 answers/question per day (see here). Voting helps other to find helpful information on the stackoverflow. So if you want help other to find information on the stackoverflow, please use voting too.
    – Oleg
    Nov 24 2011 at 12:59
2

You need parentheses to capture content and reuse it in a variable. And you should first try your rules with 302 codes, and not 301. So that if you make any mistake you do not have to close your browser to re-test the new rule (with 301 the browser is not requesting anymore the web server after the first answer).

RedirectMatch 302 ^/lang/fr/tutu/(.*) /blog/tutu/$1
2
  • Thanks, parenthesis was missing it's gerat :).
    – superscral
    Nov 24 2011 at 12:54
  • @superscral, you should accept this as the answer if it solved your problem. People will be more likely to help you if you are a 'good citizen' and do what you are supposed to in the system. See this
    – Sam Holder
    Nov 24 2011 at 14:30

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.

 
1
here you find clear explained instruction how to "accept" the answers. Additionally starting with 15 reputation point you have right to vote any helpful answers or questions which you find. You have right to vote about 30 answers/question per day (see here). Voting helps other to find helpful information on the stackoverflow. So if you want help other to find information on the stackoverflow, please use voting too. - Oleg

1 Answers

2
votes

You need parentheses to capture content and reuse it in a variable. And you should first try your rules with 302 codes, and not 301. So that if you make any mistake you do not have to close your browser to re-test the new rule (with 301 the browser is not requesting anymore the web server after the first answer).

RedirectMatch 302 ^/lang/fr/tutu/(.*) /blog/tutu/$1