簡體   English   中英

從一個站點重定向到新站點並向其中添加查詢字符串的最佳方法

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

我正在嘗試使用.htaccess從一個站點重定向到另一個站點。

但是我想在重定向將人員轉到的URL的末尾添加一個查詢字符串。 我在這里閱讀了很多文章,它們都是關於將querystring傳遞到新站點的,我只想將querystring(促銷代碼)添加到規則中。

就像是:

    <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>

我啟用了mod_rewrite。

有任何想法嗎

由於“:”和“?” 可能是格式字符串中的特殊字符,請考慮如下轉義:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM