views:

10

answers:

1

Hi!

I have two domains that are pointing to the same directory, but I would like to redirect them (via mod_rewrite in htaccess) to some specific .html when hitting home.

Like:
if (domain == 'firstdomain')
redirect firstdomain.html
else if (domain == 'seconddomain')
redirect seconddomain.html

Thanks!
Joe

+1  A: 
[..] I would like to redirect them to some specific .html when hitting home.

A language like PHP is better suited for redirecting a single page.

The following code will redirect http://example.com/ to http://example.com/example.html and http://example.org/ to http://example.org/anotherpage.html. http://www.example.com will be unaffected (note the www. part)

RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^$ example.html [R]
RewriteCond %{HTTP_HOST} ^example.org$ [NC]
RewriteRule ^$ anotherpage.html [R]

The first line matches the HTTP Host field (a.k.a. 'domain') against example.com case-insensitive (^ marks the beginning of the string, $ marks the end). If there is a match, the page will be redirected (second line, [R]) to example.html The same story for the third and fourth lines.

Lekensteyn