基于查询参数的HTAccess重定向失败?

问题描述:

正试图根据Querystring参数“ref”的存在重定向(HTAccess)一个URL。只有在存在前缀文件夹“TMP”和页面名称“domain.html”时才会重定向。 问题是重定向正在工作,但查询字符串未被传递基于查询参数的HTAccess重定向失败?

例如, http://www.olddomain.com/TMP/domain.html?ref=website-reference.com

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/TMP/domain\.html$ 
RewriteCond %{QUERY_STRING} ^ref=([0-9]*)$ 
RewriteRule ^(.*)$ http://www.newdomain.com/?ref=%1 [R=301,NE,NC,L] 

您可以使用:

RewriteEngine On 
RewriteCond %{QUERY_STRING} ^ref= 
RewriteRule ^TMP/domain\.html$ http://www.newdomain.com/ [R=301,NE,NC,L] 

在相同的查询字符串。

+1

第一次工作,非常感谢你的优秀回复。 – Barton