Mod rewrite to find a string from url and replace only the domain name of that url

I want to create a rewrite rule for .htaccess. eg: In url, if Itemid=702

found then I only want to redirect below

Source URL:

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

      

Redirect to:

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

      

I tried with below condition but it doesn't work.

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

      

How can I create this?

+3


source to share


1 answer


You're close, change the rule to:



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

      

+1


source







All Articles