Using htaccess to remove single query parameter

前端 未结 2 736
一向
一向 2021-01-14 23:24

For reasons that aren\'t worth going into here, Google have been indexing one of my sites with an unnecessary query string in the URL. I\'d like to modify my htaccess file t

2条回答
  •  不要未来只要你来
    2021-01-14 23:51

    It seems there is a mistake or something. Here is working solution:

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

    This code removes just one parameter. Working perfect.

提交回复
热议问题