Forum Moderators: phranque

Message Too Old, No Replies

Multiple domain-forwarding with script

forward, dns, domain, mapping

         

jorgo

1:37 am on Feb 29, 2008 (gmt 0)

10+ Year Member



Which is the best solution for the following task:

I have multiple domains routed to the same destination, e.g.
A-domain.com, B-domain.com and C-domain.com
-> end up on the installation Main-Domain.com

Now I need some temporary and/or permanent forwarding that routes e.g.
A-domain.com -> Main-Domain.com/A
B-domain.com -> Other-Domain.com/B
C-domain.com -> Other-Domain.com/C

I am looking for a solution where I can quickly add, change or delete the routing, kind of a bulk-rerouting.

I do not operate an own DNS.
It rather might be a solution with .htaccess, scripting or whatever ... any hints, tips & tricks?

BTW: I just found out that typo3 supports multiple domains on the same installation... how does this work and could this be adapted for my problem?

Side-question: Do search engines or browsers realize such a forwarding?

phranque

1:08 pm on Feb 29, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], jorgo!

are you using apache for all those domains?
if so, you could set up external redirects using mod_rewrite.
are all the redirects one-to-one?
will they all be temporary or permanent redirects (per domain)?
fairly simple and can be done in .htaccess context...

jorgo

2:05 pm on Feb 29, 2008 (gmt 0)

10+ Year Member



Dear phranque, thanks for your hospitality and support!

I have them all on different shared hosting servers and all are apache (but some with slight different configurations).

Almost all redirects would be one-to-one.

It's mixed temporary and/or permanent redirects about 50:50 and I talk about over 500 domains, so I'm looking for a simple solution where I can maybe edit one file quickly instead of changing at the registrar DNS or forwarding one by one.

To be honest: I don not know much about apache configuration or php coding, but with .htaccess you mean kind of adding lines like
> Redirect permanent B-domain.com [Other-Domain.com...]
This was my Idea, but I couldn't make it working.
If so, could you give me a sample?

jdMorgan

4:32 am on Mar 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're probably looking for something like this:

Redirect permanent / http://Other-Domain.com/C/

This 301-redirects all URLs which start with "/" to the same URL on other-domain.com/C/ ... In other words:
b-domain.com/<something-anything> to other-domain.com/C/<something-anything>

The URL-path specified on the left (for the "old" server where this code resides) must be a local URL-path only. See the mod_alias documentation [httpd.apache.org].

Mod_alias' RedirectMatch and mod_rewrite directives can be used to get more complex and/or conditional redirects.

Jim

jorgo

10:17 pm on Mar 3, 2008 (gmt 0)

10+ Year Member



Thanks for your suggestions! I spent some time with studying the mod_rewrite and mod_alias documentation and samples. a single forwarding wasn't any problem, but I tried about 50 versions of multiple forwardings and unfortunately none of them worked.

a) Do I have to check HTTP_HOST or HTTP_REFERER?
b) What is the correct condition/rule order when having multiple domains to different other domains?

Would it be possible to provide me with a sample htaccess e.g. with this:
*.A-domain.com/* -> Main-Domain.com/this
*.B-domain.com/* -> Other-Domain.com/that
*.C-domain.com/* -> Other-Domain.com/there

jdMorgan

12:17 am on Mar 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jorgo,

We don't do that here... Please review our forum charter [webmasterworld.com]. We'll be glad to help you learn to do it yourself, or you can try searching this forum [google.com] for previous threads on this subject, of which there are many.

Jim