skip to Main Content

I want to redirect to URL when my query string is equal to -this-is-test1

Redirect /search/product/basecamp?-this-is-test1 https://www.some-example.com/search/product/result-this-is-test1

Note: There is the only value not any key in the query string.

2

Answers


  1. Could you please try following, make sure you clear your browser cache after placing these rules into yout .htaccess file.

    RewriteEngine On
    RewriteCond %{THE_REQUEST}  s/(search/product)/basecamp?(-this-is-test1)s [NC]
    RewriteRule ^(.*)$ /%1/result%2? [NE,L,R=301]
    
    Login or Signup to reply.
  2. You cannot match query string in Redirect or RedirectMatch directives.
    You may use this rule based on mod_rewrite module:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} (-this-is-test1) [NC]
    RewriteRule ^(search/product)/basecamp/?$ /$1/result%1? [NE,L,R=301,NC]
    

    ? at the end of target will strip any query string.

    References:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search