重定向整个域与除一个其对应的URL和查询字符串

问题描述 投票:1回答:1

我在我的.htaccess的规则与重定向的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]
.htaccess
1个回答
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]
© www.soinside.com 2019 - 2024. All rights reserved.