There are many ways to do this. I just give you the most straightforward (of course for me!) and simplest one.
hook_preprocess_html use this code
$host = $_SERVER['HTTP_HOST']. request_uri();
I can't test this code right now, but this is the main idea:
Get current url components separately, the host (
$_SERVER['HTTP_HOST']) and what comes after it (
request_uri()), if its
example2 as a substring, then redirect the user to
For redirection you can also use
drupal_goto or anything else you want I just gave you the pure PHP.