Forum Moderators: phranque
I have 25 domains which 20 of them need to forward to one domain and the other 3 need to forward to another domain and 2 to yet another domain.
Also, I would like domain1.com as well as www.domain1.com to go to the other domain.
I have, for example:
www.domain1.com
www.domain2.com
www.domain3.com
I want those forwarded with mod_rewrite to: www.bigwebsite.com
Then I have:
www.domain4.com
www.domain5.com
www.domain6.com
and I want those forwarded with mod_rewrite to: www.mediumwebsite.com
then I have
www.domain7.com
www.domain8.com
and I want those forwarded with mod_rewrite to: www.smallwebsite.com
-----------------
This is where it gets tricky.
In my httpd.conf, I have my root www directory at:
/home/httpd/
because I have all of MY websites there.
The clients websites are in their home directories, so I create a name-based virtual host container for each of them.
<VirtualHost *:80>
ServerName domain1.com
ServerAlias *.domain1.com
DocumentRoot /home/client/www/domain1
ServerAdmin webmaster@domain1.com
</VirtualHost>
etc., etc.
The domains that I want forwarded and the domains I want them forwarded to are in (example):
/home/client/www/domain1
/home/client/www/domain2
/home/client/www/domain3
/home/client/www/domain4
/home/client/www/domain5
/home/client/www/domain6
/home/client/www/domain7
/home/client/www/domain8
/home/client/www/smallwebsite
/home/client/www/mediumwebsite
/home/client/www/bigwebsite
These are all, like I mentioned above, in the httpd.conf file as name-based virtual hosts.
So yeah... it's had me pretty stumped as to how to go about doing this. I don't even know what I'm supposed to have in httpd.conf and if I need something in an .htaccess file in the /home/client/www/ directories... so any reply that is as "n00bish" as you can make it would be greatly appreciated...
[edited by: UniquelyAm at 9:54 pm (utc) on Aug. 30, 2007]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^w*\.domain1\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^*\.domain1\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC,OR]
RewriteRule ^(.*)$ http://www.bigwebsite.com/$1 [R=301,L]
Well I tried this at first but ended up messing around a bit more and discovered that this, below, works for www and no www, as well.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^\.domain1\.com$ [NC]
RewriteRule ^(.*)$ http://www.bigwebsite.com/$1 [R=301,L]
So I guess I don't need anyones help after all. Thanks anyway.
Amber.
[edited by: jdMorgan at 1:41 pm (utc) on Aug. 31, 2007]
[edit reason] De-linked [/edit]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^\.domain1\.com$ [NC]
RewriteRule ^(.*)$ http://www.bigwebsite.com/$1 [R=301,L]
I'd suggest:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
You could also put the code into example1's <VirtualHost> container in httpd.conf, with a small change:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com [NC]
RewriteRule [b]^/([/b].*)$ http://www.example.com/$1 [R=301,L]
Sorry you didn't get an immediate response to your thread; Participation in this forum is limited, and contributors are few.
Jim
I don't know why I thought about stopping back by this thread, but I'm glad I did now.
Thank you so very much for the response!
I pasted the wrong code. I tried the one I pasted before I tried this one:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
RewriteRule ^(.*)$ [bigsite.com...] [R=301,L]
The other one DID work, so I added the code to the 25 domains directories .htaccess files. Then I tried it again and it stopped working! So I'm guessing something was cached. But I rewrote it to what I just posted, went back through 25 domains .htaccess files... again :( ... and tried it and this definitely works for both www. and without.
It's still redirecting to the page I want them to this very minute.
BUT, I like your idea better. I would really like having one code added to one location ( the virtual containers in the httpd.conf file ) instead of 25 different .htaccess files in 25 different directories...
I'm definitely going to try your idea. Plus I'd get an extra variation covered ( the example1.com:80 ).
Anyway, thanks again, jd, very much. I'm just glad to get a helpful response at all.
Take care and best wishes,
Amber.
UniquelyAm
p.s. Apologies for throwing the .com after my user name, jd.
I normally add my user name, UniquelyAm, after my real name and was thinking about my site at the time and added the .com to the end of my user name, but really didn't mean to.
-True story-
I mean I even went to the trouble of taking the domains out of the urls I posted throughout this thread and making them domain1, etc., instead of leaving them what they actually were.
Again, thanks jd, for everything. I'm going to try your suggestion after I get a few hours of sleep.
Take care ~ am.