Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

2 domain and .htaccess and 2 diffrent files



4:18 pm on Jan 5, 2003 (gmt 0)

Inactive Member
Account Expired


I have 2 domain. www.damain1.pl and www.domain2.pl. I would like to prepere htaccess file, that will loda file index1.php when somebody typy www.domain1.pl or file index2.php when sombody type www.domain2.pl.

I have something like this:

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} www.domain1.pl
RewriteCond %{REQUEST_URI}!index1/
RewriteRule ^(.*)$ index1/$1 [L]

RewriteCond %{HTTP_HOST} www.domain2.pl
RewriteCond %{REQUEST_URI}!index2/
RewriteRule ^(.*)$ index2/$1 [L]

but this change main directory, and i need to load file www.domain1.pl/index1.php or www.domain2.pl/index2.php
thanks a lot.

5:12 pm on Jan 5, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
votes: 0


If I understand your requirements, the following should work. Note the order of the Options and the RewriteEngine directives. The value of %1 in the first RewriteRule is taken from the grouped class (-one¦-two) in the RewriteCond, and this rewrite will accept either www.domain-one.pl or www.domain-two.pl.

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain(-one¦-two)\.pl
RewriteRule ^$ /index%1.php [L]

If you also want to allow users to access your site using "http://domain1.pl" (without "www"), then you can modify the above:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain(-one¦-two)\.pl
RewriteRule ^$ /index%2.php [L]

These rewrites illustrate the use of backreferences to variables in the RewriteCond, whereas most simple rewrites use backreferences to variables only in the RewriteRule itself. Apache mod_rewrite documentation [httpd.apache.org]

Note thet you will need to edit the "¦" characters in the above code, and replace them with the "¦" character on your keyboard, usually "SHIFT \".