php - subdomain redirection 301 is not working -


i using .htaccess code 301 redirection subdomain domain. , using domain.php?id=123 , need redirect domain name. codes below.

  rewriteengine on   rewritecond %{http_host} !^http://www.domain.com/dom.php?id=12$   rewriterule (.*) http://www.domain.com/ [r=301,l] 

but when trying this, got error like, redirect http://www.domain.com/?id=12 page

you cannot match request_uri , query_string using rewritecond %{http_host}, try this:

rewriteengine on  rewritecond %{query_string} ^id=123$ rewriterule ^dom\.php$ /? [r=301,l,nc] 

this redirect http://www.domain.com/dom.php?id=12 http://www.domain.com/.

or redirect http://www.domain.com/dom.php?id=<number>:

rewritecond %{query_string} ^id=\d+$ rewriterule ^dom\.php$ /? [r=301,l,nc] 

Comments