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

时间:2017-09-14 08:09:25

标签: .htaccess redirect query-string

我正在尝试根据Querystring Paramater“ref”的存在重定向(HTAccess)一个URL。仅当存在前缀文件夹“TMP”且页面名称为“domain.html”时才重定向。 问题是重定向正在运行,但Querystring没有传递

e.g。 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]

1 个答案:

答案 0 :(得分:1)

您可以使用:

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

使用相同的查询字符串。

相关问题