Absolutly. You can even use subdomains for both domain names. I did some experimentation with my website and got it to work using code like this:
Code:
RewriteEngine On
RewriteBase /
# BEGIN REDIRECT CODE FOR TWO DOMAINS WITH SUBDOMAINS
# (Note: The following three lines may be
# copied and repeated for each subdomain.)
RewriteCond %{HTTP_HOST} sub.domain1.com
RewriteCond %{REQUEST_URI} !subdir1/
RewriteRule ^(.*)$ subdir1/$1 [L]
RewriteCond %{HTTP_HOST} sub.domain2.com
RewriteCond %{REQUEST_URI} !subdir2/
RewriteRule ^(.*)$ subdir2/$1 [L]
Code:
# The lines for a second domain follow...
# Note: This must be after all other lines for subdomains.
RewriteCond %{HTTP_HOST} domain2.com
RewriteCond %{REQUEST_URI} !domain2/
RewriteRule ^(.*)$ domain2/$1 [L]
# END OF REDIRECTION CODE
What this does is redirects:
sub.domain1.com to subdir1
sub.domain2.com to domain2/subdir2
domain2.com to domain2
If you don't want to use subdomains for the second domain, simply remove those lines from your htaccess file.
Good luck :)