这是使用Apache Vhost配置
重定向到新域的后续问题我想要我的请求
某种程度上: 要重定向到 womerotherdomain.com/dell-inspiron-15 ,但对于某些被列入白名单的产品有选择性。 例如,产品: 重定向到新URL,但对于任何其他产品,我都想使用当前路径本身。 当前我的VHOST配置如下所示。它将查询参数中的所有产品重定向到某些产品。 问题: 这里的任何线索都非常感谢。Listen 12567
NameVirtualHost *:12567
<VirtualHost *:12567>
ServerName somedomain.com
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^|&)product=([^&]+) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]
</VirtualHost>
由于您有少量型号,因此您可以将它们列出,例如:
RewriteEngine On
RewriteCond %{QUERY_STRING} (?:^|&)product=(Dell-Inspiron-15) [NC,OR]
RewriteCond %{QUERY_STRING} (?:^|&)product=(Dell-Inspiron-16) [NC,OR]
RewriteCond %{QUERY_STRING} (?:^|&)product=(Dell-Inspiron-17) [NC]
RewriteRule ^/?loadproduct$ http://someotherdomain.com/%1? [R=301,L,NC]
默认情况下,用每条线之间的操作解释了重新值。因此,在触发重写之前,每个条件都必须为真。在这里,在行之间使用或操作员。只要一个匹配,您就可以了。