Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0 support forum
 Helicon Tech : ISAPI_Rewrite 3.0 support forum
Subject Topic: Redirect a Number of Domains to One Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
dickbob
Newbie
Newbie


Joined: 30 August 2007
Online Status: Offline
Posts: 30
Posted: 20 September 2008 at 1:09pm | IP Logged Quote dickbob

How can I redirect permanently...

foo.com
bar.com
this.com
that.net

...to...

foobar.com
Back to Top View dickbob's Profile Search for other posts by dickbob
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 23 September 2008 at 1:43am | IP Logged Quote Anton

RewriteCond %{HTTP_HOST} ^(?:(?:foo|bar|this)\.com|that\.net)$ [NC]
RewriteRule .? http://foobar.com [R=301,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
dickbob
Newbie
Newbie


Joined: 30 August 2007
Online Status: Offline
Posts: 30
Posted: 23 September 2008 at 3:16am | IP Logged Quote dickbob

That's not quite working as I want but I think that's my fault for trying ask a too generic question.

What I was looking for was...

www.foo.net
www.foo.org

...to go to...

www.foo.com

So I tried to learn from your code and did this...

RewriteCond %{HTTP_HOST} ^www\.foo\.(?:net|org)$ [NC]
RewriteRule .? http://www.foo.com/ [R=301,L]

...and that seems to work for me.

For my future benefit, and anyone else trying to learn rather than rely on the good services of Anton, what that code is saying is...

Anything starting www.foo. and ending either net or org redirect permanently to www.foo.com

Anton, do you agree with my code and my interpretation of what's going on?
Back to Top View dickbob's Profile Search for other posts by dickbob
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 25 September 2008 at 9:16am | IP Logged Quote Anton

Yes, sure, you are absolutely correct!

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
Conq
Newbie
Newbie


Joined: 20 February 2008
Location: Denmark
Online Status: Offline
Posts: 8
Posted: 08 October 2008 at 3:44am | IP Logged Quote Conq

What if I want fu.net and bar.com to redirect to fubar.com, but not fu.com or bar.net?

 

Should add that I have a list of 50 domains I need to redirect to a single domain and was hoping there was an easy way.

Back to Top View Conq's Profile Search for other posts by Conq
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 09 October 2008 at 3:03am | IP Logged Quote Anton

You may consider using map files. You may have pairs like:
fu.net fubar.com
bar.com fubar.com
etc.

And use the following config:

RewriteBase /
RewriteMap mapfile txt:mapfile.txt
RewriteMap lower int:tolower
RewriteCond %{HTTP_HOST} (.*)
RewriteCond ${mapfile:${lower:%1}|NOT_FOUND} !NOT_FOUND
RewriteRule .? http://${mapfile:%1} [R=301,L]


__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
Conq
Newbie
Newbie


Joined: 20 February 2008
Location: Denmark
Online Status: Offline
Posts: 8
Posted: 09 October 2008 at 4:44am | IP Logged Quote Conq

Nice. Will try that.

Will it work together with other rules I already have? Like adding www.

Back to Top View Conq's Profile Search for other posts by Conq
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 13 October 2008 at 2:23am | IP Logged Quote Anton

Sure it will work with other rules, but then consider adding www part to map files records (if you are adding www prior to map file rules
execution).

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum