Forum Moderators: phranque

Message Too Old, No Replies

Subdomain redirection - modrewrite

I need a subdomain to redirect to different domain.

         

TerryLM

1:44 am on Dec 12, 2005 (gmt 0)

10+ Year Member



I need a subdomain like this:
sub.domain1.com

to redirect to:
sub.domain2.com

This isn't a problem. I need the sub.domain2.com to be appear to be sub.domain1.com.

So if you type in sub.domain1.com/dir/home/

it should actually go to sub.domain2.com/dir/home/ and still retain

sub.domain1.com/dir/home in the URL bar at the top.

I can't find how to do this anywhere on google. I know you can do it with 1 domain and different directories, but I don't know if I can do it accross domains themselves.

If this isn't the best way to go about this, how can I do it without using frames or something lame like that?

Thanks
-Terry

jdMorgan

1:59 am on Dec 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Terry,

Welcome to WebmasterWorld!

The critical question here is whether the subdomain and the target domain reside on the same server. If so, then you can either configure httpd.conf to 'steer' the subdomain requests to a different filespace, or do a rewrite in httpd.conf or in .htaccess. You cannot use any kind of redirect, because that involves the client and will force an update of the client browser's address bar and make search engines aware of the URL change.

If not. then you will have to set up the subdomain as a proxy server for the domain. What this means is that all traffic for domain must pass through subdomain to domain, and all responses from domain must then pass back through subdomain. So subdomain's workload in the request and response handling phase increases, while it sees no increase in the content-handling phase. Another downside is that domain will always see subdomain as the requesting IP address, so tracking and logging for domain needs to remain on subdomain unless you modify the tracking and logging software to examine the "HTTP_FORWARDED_FOR" HTTP header.

So we need to know where subdomain and domain are hosted, and whether you have access to the httpd.conf serve config file on subdomain.

Jim

TerryLM

2:26 am on Dec 12, 2005 (gmt 0)

10+ Year Member



the domains are both hosted on the same server, I can edit the httpd.conf and everything.

What coding do I use to accomplish this?

jdMorgan

2:40 am on Dec 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out the ServerName and ServerAlias directives in Apache core [httpd.apache.org] to start. I can't give you 'the code' for a couple of reasons; First, every server is different and this is 'deep stuff' modifying your server config. For the second reason, please review our forum charter [webmasterworld.com].

The Apache Virtual Hosts documentation [httpd.apache.org] may also be helpful.

Jim