简体   繁体   中英

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

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM