Rewriting a variable in a querystring with .htaccess

前端 未结 1 990
面向向阳花
面向向阳花 2021-01-25 06:11

I use a PHP script with my site that produces a querystring in the URL. One of the variables in the querystring is: colour=red

I would like to make a rule i

1条回答
  •  终归单人心
    2021-01-25 06:57

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^(.*&|)colour=red(&.*|)$  # search colour=red
    RewriteRule ^(.*)$ $1?%1colour=blue%2 [L,R=301]       # redirect to colour=blue
    

    This will redirect URLs with colour=red in query-string to URLs with colour=blue

    0 讨论(0)
提交回复
热议问题