这是关于>重定向到新域的后续问题使用apache vhost配置
我希望我的请求
somedomain/loadproduct?product=dell-inspiron-15
要重定向到
someotherdomain/dell-inspiron-15
,但有选择地针对列入白名单的某些产品.
but selectively for some products which are whitelisted.
例如产品:
重定向到新的URL,但是对于其他任何产品,我都想使用当前路径本身.
redirect to the new URL but for any other products I want to use the current path itself.
当前,我的虚拟主机配置如下所示.对于查询参数中的所有产品,它将重定向到某个其他域.
Currently my vhost configuration looks like below. It redirects to someotherdomain for all the products in query parameter.
Listen 12567 NameVirtualHost *:12567 <VirtualHost *:12567> ServerName somedomain ProxyPreserveHost On RewriteEngine On RewriteCond %{QUERY_STRING} (?:^|&)product=([^&]+) [NC] RewriteRule ^/?loadproduct$ someotherdomain/%1? [R=301,L,NC] </VirtualHost>问题:
这里的任何潜在顾客都非常感激.
Any leads here is really appreciated.
推荐答案由于模型数量较少,因此可以将它们列出来,如下所示:
Since you have a small number of models, you could just list them out, like so:
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$ someotherdomain/%1? [R=301,L,NC]默认情况下,RewriteCond行通过每行之间的AND操作进行解释.因此,在触发RewriteRule之前,每个条件都必须为TRUE.这里在两行之间使用或"运算符.只要一场比赛,你就可以.
By default, RewriteCond lines are interpreted with the AND operation between each. So each condition must be TRUE before the RewriteRule is triggered. Here use the OR operator between the lines. As long as one matches, you are ok.
更多推荐
使用apache vhost配置选择性地重定向到新域
发布评论