Forum Moderators: phranque

Message Too Old, No Replies

URL detection redirect

         

planetsamus

11:06 pm on Apr 17, 2004 (gmt 0)



Hello all,

I'm fairly new to apache servers, so I'm hoping someone has some advice or help for me. I've looked through many of the redirect threads about using .htaccess, but I'm still not sure what I need to do for my situation.

Here's what I own.

www.mydomain.com
www.domain1.com
www.domain2.com

The DNS for all 3 domains all point to www.mydomain.com. The acual home page for www.domain1.com is at www.mydomain.com/d1/index.html and the home page for www.domain2.com is www.mydomain.com/d2/index.html.

Is there a way (and what is it) to detect what URL the user typed into his browser and send him to the correct place? So that if he types www.domain2.com he gets sent to www.mydomain.com/d2/index.html?

I do not have the option to change the DNS settings, so I need to find a way to do this with .htaccess (or I guess JS if the .htaccess method doesn't exist.

Thanks.

jdMorgan

1:35 am on Apr 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



planetsamus,

Welcome to WebmasterWorld [webmasterworld.com]!

> Is there a way (and what is it) to detect what URL the user typed into his browser and send him to the correct place? So that if he types www.domain2.com he gets sent to www.mydomain.com/d2/index.html?

Yes, this is a fairly easy exercise. See the first post and follow the links in this Introduction to mod_rewrite [webmasterworld.com] thread.

Create a back-reference to the part of the domain name that changes in the pattern, and use it in the URI substitution.

Jim