homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

2 domain and .htaccess and 2 diffrent files

10+ Year Member

Msg#: 91 posted 4:18 pm on Jan 5, 2003 (gmt 0)

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.



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

Msg#: 91 posted 5:12 pm on Jan 5, 2003 (gmt 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 \".


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved