I have tried the below mentioned option but its not working. The condition passes when both are equal AND when both the values are not equal.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^%{SERVER_ADDR}
RewriteRule ^(.*) http://hostIsDifferent [R=301,L]