Hello. I transfer the site to a new engine and do not save the page addresses. I decided to make a 301 redirect On the old site, the page looked like http://site.ru/?a=category&b=1 On the new http://site.ru/category The domain is the same Thank you very much to everyone who responds
Closed due to the fact that the essence of the issue is incomprehensible to the participants by cheops , rjhdby , aleksandr barakin , HamSter , user207618 10 Oct '16 at 23:24 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
- Possible duplicate question: How to do everything at once in mod_rewrite? - aleksandr barakin
|
1 answer
RewriteCond %{QUERY_STRING} a=([^&]*)[NC] RewriteRule .* /%1? [R=301,L] % {QUERY_STRING} is used to work with GET parameters. if in parameters there is a parameter "a", we remember its value and use it in the new URL (entry% 1).
- NC Independent Validation
- R = 301 There will be a redirect with the code 301, you can specify another code
- L This is the last rule, no longer apply transformation rules.
- at the end of the sign "?" - We need it to cut off the original GET parameters, otherwise we will get http://site.ru/category?a=category&b=1
- Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky ♦
- Your rule is written with an error. The final URL will be
http://site.ru/category&b=1, and the author clearly did not want this. It will be correct to use([^&]*)instead of(.*)([^&]*). Correct your answer, please. - VenZell - @VenZell corrected - Alex
|