In the .htaccess file I try to redirect from URLs like http://site.ru/?amp;id=ХХ&catid=XX to the main page, i.e. on http://site.ru/ , but it does not work. I tried this:

 RewriteEngine On RewriteCond %{QUERY_STRING} ^amp;id=(\d+)&catid=(\d+)$ [NC] RewriteRule ^/$ http://site.ru/ [R=301,L] 
  • at least, RewriteRule does not get a leading slash, to wrap everything up, write, for example, RewriteRule ^ http://site.ru/ [R=301,L] And if only empty uri, then RewriteRule ^$ http://site.ru/ [R=301,L] - splash58
  • Try this ^ ( site.ru/) (. *?) $ Index.php [R = 301, L] - Vanya Avchyan

1 answer 1

Use this design to redirect:

 RewriteEngine On RewriteCond %{QUERY_STRING} \bid=\d+\b [NC] RewriteCond %{QUERY_STRING} \bcatid=\d+\b [NC] RewriteRule ^$ http://site.ru/? [R=301,L] 

Separate rules for the variables id and catid introduced so that there is no binding to the order. The \b bounds are used here to exclude rules from triggering on a part of the string, for example, pid=11gg . In RewriteRule , ^$ to react only to the url of the form http://site.ru/?... , and the question mark in the site address is right there for deleting variables during redirection.