Best way to redirect from one site to new site adding a querystring to it

57 views Asked by At

I am trying to redirect with .htaccess from one site to another.

However I want to add a querystring to the end of the URL that the redirect takes the person to. I have read lots of articles on here and they are about passing the querystring along to the new site, I just want to ADD a querystring (a promo code) to the rule.

Something like:

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteCond %{HTTP_HOST} site.com$ [OR]
       RewriteCond %{HTTP_HOST} ^www.site.com$
       RewriteRule (.*)$ https://www.newsite.com/subscribe.aspx?code=xxke [R=301,L]
 </IfModule>

I have mod_rewrite enabled.

Any ideas

1

There are 1 answers

1
Yaroslav On BEST ANSWER

Since ":" and "?" may be special characters in format strings consider escaping them as follows:

RewriteRule (.*)$ https\://www.newsite.com/subscribe.aspx\?code=xxke [R=301,L]