1) in general, I want everything on www.ABC.com to be redirected to www.XYZ.com
2) EXCEPT when it's www.ABC.com/this/123([a-z]+).html ... it must Rewrite (NOT redirect) to ... www.ABC.com/that_script.php?var=123
3) Also EXCEPT: when it's www.XYZ.com/this/123([a-z]+).html ... it must go (redirect) to .... www.ABC.com/this/123([a-z]+).html (so the 2nd rule will apply after that)
EDIT Both domains parked on the same hosting, so sharing the same HTACCESS
EDIT2 Language of the project is PHP
I tried various RewriteCond with %{REQUEST_URI} or %{SCRIPT_FILENAME} but it never works, either saying it's an infinite loop or simply don't take the condition at all.
EDIT3 In PHP, it would looks like that...
if( FALSE !== strstr($_SERVER['HTTP_HOST'], 'ABC.com') && FALSE !== strstr($_SERVER['SCRIPT_FILENAME'], 'that_script') ) {
header("Location: http://www.XYZ.com".$_SERVER['REQUEST_URI'],TRUE,301);
}
if( FALSE !== strstr($_SERVER['HTTP_HOST'], 'XYZ.com') && FALSE === strstr($_SERVER['SCRIPT_FILENAME'], 'that_script') ) {
header("Location: http://www.ABC.com".$_SERVER['REQUEST_URI'],TRUE,301);
}
I want this, but in HTACCESS