There is a task to replace one variable for another in URLs with GET-variables (the difference is only in the case of characters). For a single page, it looks like this:

RewriteCond %{QUERY_STRING} ^categoryid=418$ RewriteRule ^index\.php$ http://www.site.ru/index.php?categoryID=418 [R=301,L] 

How to write a rule for any category number, taking into account the fact that there may be other variables in the string after categoryID ?

    1 answer 1

     RewriteEngine On RewriteCond %{QUERY_STRING} ^(.*?)categoryid=([^&]+)(.*)$ RewriteRule ^index\.php$ /index.php?%1categoryID=%2%3 [R=301,L] 

    From %{QUERY_STRING} you need to capture all the data in order to transfer them correctly to the redirect. The %1 group gets the start of %{QUERY_STRING} before the categoryid variable, the %2 group falls into the group %2 contents, and %3 %{QUERY_STRING} ends the group %3 .

    Here /index.php?%1categoryID=%2%3 they all return to their places with categoryid= replaced by categoryID= .