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/$1 [R,L]