Forum Moderators: phranque

Message Too Old, No Replies

Subdomain with www.

Redirect to an ip address from the virtual host file

         

chicagoguy2008

12:10 am on Dec 8, 2008 (gmt 0)

10+ Year Member



Hello, I am posting this as one of our main server guys is out of the office and I need to take care of this soon. Here is the situation:

I have a virtual host file with the following entries...

<VirtualHost *:80 *:81 *:82>

ServerName www.test.com
ServerAlias test.com
ServerAdmin test@test.com
DocumentRoot /data02/oracle/oracleas_web/ohs/htdocs

Redirect 301 /digital http://200.**.132.20/

So we bought http://digital.test.com and we redirected to the ip address specified.
Now we want http://www.digital.test.com to go to the same ip address - can someone please tell me how to do that?

Thanks in advance for all your help.

[edited by: jdMorgan at 12:39 am (utc) on Dec. 8, 2008]
[edit reason] Obscured IP address, de-linked URLs. [/edit]

jdMorgan

12:40 am on Dec 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I hope you didn't really *buy* a subdomain, since you can freely create as many subdomains as you like under your "test.com" domain...

This is not usually a problem solved in the server itself. Rather, you should simply modify your DNS zone file to point the subdomain digital.test.com and the sub-sub-domain www.digital.test.com to your "digital server's" IP address.

Jim

[edited by: jdMorgan at 12:41 am (utc) on Dec. 8, 2008]

chicagoguy2008

1:01 am on Dec 8, 2008 (gmt 0)

10+ Year Member



Thanks for your response Jim. Yes - we did not buy it - we probably asked our hosting service to put an entry to that effect. However even after modifying the dns zone file, I was under the assumption that I will have to modify the hosts file too - as this host file recognizes www.test.com and not www.digital.test.com.
Basically our setup is like this:

We have one httpd.conf file and a vhost file for each of the other domains. So in this case we have a vhost file called www.test.com.vconf and within that we have the following:

<VirtualHost *:80 *:81 *:82>

ServerName www.test.com
ServerAlias test.com
ServerAdmin test@test.com
DocumentRoot /data02/oracle/oracleas_web/ohs/htdocs

Redirect 301 /digital [200.**.132.20...]

</VirtualHost>

So I am thinking maybe i should create another virtualhost entry for www.digital.test.com?

Am i on the wrong track?

Thanks

jdMorgan

1:23 am on Dec 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That very much depends on exactly where the 200.**.132.20 IP address you spoke of resolves to -- Does it resolve to this same physical server machine, or to another machine? The vHost needs to be created on that machine, wherever it is.

I assume that your next step is to get rid of the redirect to the IP address in the www.test.com vHost, and replace it with a redirect or a proxy through-put to the new digital.test.com hostname?

Jim

chicagoguy2008

1:31 am on Dec 8, 2008 (gmt 0)

10+ Year Member



The 200.**.132.20 ip resolves to a different server - on a completely different host. We do not have permissions to modify that - it is an external website.
This problem arose as they publicized the wrong url - instead of specifying [digital.test.com...] they gave it out as [digital.test.com...] So now I am trying to route all traffic from [digital.test.com...] to [digital.test.com....] That in turn will route it to the IP address.

jdMorgan

3:36 pm on Dec 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, so a VirtualHost for www.digital.test.com configured on the test.com server containing an unconditional redirect to digital.test.com is all that's needed.

An alternative would be to add a ServerAlias for www.digital.test.com in the www.test.com vHost container on the test.com server, and then conditionally redirect to digital.test.com if the requested hostname is www.digital.test.com. This can be done with mod_rewrite and a RewriteCond examining the %{HTTP_HOST} variable.

Jim

[edited by: jdMorgan at 3:38 pm (utc) on Dec. 8, 2008]