Forum Moderators: phranque
RewriteEngine On
RewriteCond %{HTTP_HOST} ^((www\.)?example2\.net¦example\.com)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
example.com is the domain I am attempting to redirect parked domains to. example2.net is a parked domain. I need to add several additional parked domains, but not sure of the syntax.
RewriteCond %{HTTP_HOST} ^(www\.)?example2\.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Then you can look at grouping them with regular expressions if you want ;)
The second RewriteCond above would have caused an 'infinite' redirection loop, because it would have redirected www.example.com to itself repeatedly. The fix for that ties in with your new question, and the answer is to remove the (www\.)? from that RewriteCond, and use it as shown here as the first RewriteCond:
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example2\.net [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co\.uk [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
Your fix seemed to work. All parked domains are redirecting BUT, something strange is happening. None of my css styles are working. Basically, I am looking at a html doc with no attached styles.
In case you are wondering, no I have not made any recent changes to any of the styles or pages.
"Redirection limit for this URL exceeded. Unable to load requested page. This may be caused by cookies that are blocked"
Here is the 301 I set:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example2\.net [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example3\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example4\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example5\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?example6\.com [NC,OR]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
I am new to Apache as if you could not tell. Where is the best place to learn what all the little files on the server are. For example, .bash_profile?
Getting used to mod_rewrite takes some time. But you'll find it worth the investment... ;)
Jim