How do I redirect example2.com to example.com My website has 2 domain, example.com and example2.com.

example.com/node/1 and example2.com/node/1 are the same link.

How do I redirect example2.com to example.com.

When people open the linke example2.com/node/1, it will redirect to example.com/node/1
There are many ways to do this. I just give you the most straightforward (of course for me!) and simplest one.

In hook_preprocess_html use this code

THEME_preprocess_html(&amp;$var){
      $host = $_SERVER['HTTP_HOST']. request_uri();
      if(strpos($_SERVER['HTTP_HOST'],'example2') !=false)   
           header("location:example.com/".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 $_SERVER['HTTP_HOST'] contains example2 as a substring, then redirect the user to example.com/request_uri()

For redirection you can also use drupal_goto or anything else you want I just gave you the pure PHP.