Hi, I have some problem, and could not find an answer online. I always used an .htaccess for redirecting, but it is not working properly with my new hoster. So, I have a problem. I have various domains, pointing in one hosting account all on the same website. Now I want to use only one of the domains to be the official domain, with www. Si I did this in my .htaccess: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.maindomain.com$ [NC] RewriteRule ^(.*) http://maindomain.com/$1 [L,R=301] So far, so good. It`s working. But now I want all the other domains also to redirect into this maindomain. Means: The user enters one of my domain names and gets redirected (301) to the www.- version of my maindomain.com Does anybody know what I have to do, to make it work?! Let me know, thanks! Your help is very much apprechiated. Jab
Hmm, I found a good idea: RewriteEngine on RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^maindomain\.com RewriteRule (.*) http://maindomain.com/$1 [R=301,L] The only question for me now is: Hoch do I get this redirect point into www.maindomain.com and not maindomain.com. Any ideas? Thanks.
RewriteEngine on RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^maindomain\.com RewriteRule (.*) http://www.maindomain.com/$1 [R=301,L]
The RewriteCond also has to check against the www domain: RewriteEngine on RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.maindomain\.com RewriteRule (.*) http://www.maindomain.com/$1 [R=301,L] .. otherwise it'll create an infinite loop.
Thanks a billion for your help. BTW: Do you know a good online resource to get some more, or all information on htaccess coding?! I wanna dive into this...I always tried to avoid it, but I wanna learnit now. Thanks again for your help. Jab