mod 重写从 url 中搜索字符串的规则并仅替换 url 的域名

mod rewrite rule for searching a string from url and replace just domain name of that url

我想为 .htaccess 创建重写规则。 例如: 在 url 中,如果找到 Itemid=702 那么我只想重定向到下面

原URL是:

www.dashboard.example.com/comp/temp/health/appt?Itemid=702

重定向至:

www.admin.example.com/comp/temp/health/appt?Itemid=702

我试过以下条件,但它不起作用。

RewriteCond %{REQUEST_URI} Itemid=702$
RewriteRule .* http://admin.example.com [R,L]

我该如何创建它?

你很接近,将规则更改为:

RewriteCond %{QUERY_STRING} Itemid=702 [NC]
RewriteRule (.*) http://admin.example.com/ [R,L]