.htaccess中有一条规则,该规则将整个域及其URL和查询字符串重定向到一个新域。但是,我想从中排除一个URL。我仍要重定向该URL,以从中删除查询字符串。因此,对于https://www.test1.com/search?type=content,应将其重定向到https://www.test.com/search,以除去查询字符串,但对于其余的URL,以下内容就可以了。
# Redirect users from test1.com to https://www.test.com
RewriteCond %{HTTP_HOST} ^(www.)test1\.com$ [NC]
RewriteRule ^ https://www.test.com%{REQUEST_URI} [R=301,L]
答案 0 :(得分:0)
您可以使用此:
#redirect and discard querystring from /search?type=content
RewriteCond ℅{THE_REQUEST} /search/?\?type=content [NC]
RewriteRule ^ https://www.test.com%{REQUEST_URI}? [R=301,L]
# Redirect users from test1.com to https://www.test.com
RewriteCond %{HTTP_HOST} ^(www.)test1\.com$ [NC]
RewriteRule ^ https://www.test.com%{REQUEST_URI} [R=301,L]