RewriteEngine on

# remove .php 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

# redirect www.domain2.com and domain2.com to domain.com
RewriteCond %{HTTP_HOST} ^www.domain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^domain2.com$ [OR]

# redirect www.domain.com to domain.com
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteRule (.*)$ http://domain.com/$1 [R=301,L]