It is necessary to make a redirect if the "? Start =" parameter is specified after the root slash (that is, on the main page). For example:

"site.com/?start=16" - should redirect to "site.com/"

"site.com/my-publishment?start=16" - should remain as is

I tried this code:

RewriteCond %{QUERY_STRING} ^(.*)start=[^&]+(.*)$ [NC] RewriteRule ^(.*)$ /$1?%1%2 [R=301,L] 

but he redirects me in all cases, instead of doing it only on the first

    2 answers 2

    Try this:

     RewriteEngine On RewriteCond %{QUERY_STRING} \bstart=[^&]+ RewriteRule ^$ /? [R=301,L] 

    Regular ^$ just will respond only to requests like site.com/?start=16 , that is, going to the root of the site.

      I did it myself first (code below), and then I tried another option from @Visman. Both options are working, if only there is not one "but": when the start parameter is 16, for some reason it disappears even where it should remain. For some reason, everything is fine with the other values ​​of this parameter. My code is:

       RewriteCond %{QUERY_STRING} ^/\?start=[^&]+$ [NC] RewriteRule ^(.*)$ /$1 [R=301,L] 

      Work: /page?start=15 ; /page?start=17 ; /page?start=8 ; /page?start=32 ...

      Does not work: /page?start=16 .