subdomain pass through

This is a discussion on subdomain pass through within the Apache Web Server forums, part of the Web Server and Related Forums category; Recently we migrated an entire development/internal domain to fully qualified external domain name. We have already updated the DNS ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-24-2007
MWE Computer Services
 
Posts: n/a
Default subdomain pass through

Recently we migrated an entire development/internal domain to fully
qualified external domain name. We have already updated the DNS for
both the old site to point to our redirect server and new site domain
location. The problem we have now is that we cannot redirect from the
old subdomain.domain.com name to the new subdomain.newdomain.com one.

We are running Apache 1.3.37 on HP-UX 11.23 with mod_alias and
mod_rewrite available.

This is what is needed to happen: site1.domain.com -->
site1.newdomain.com

I wrote the following out as per our virthosts-redirect.conf file on
the redirect server:

<VirtualHost redirect.ourdomain.com>
ServerName domain.com
ServerAlias www.domain.com
ServerAlias *.domain.com
CustomLog /dev/null common
ErrorLog /dev/null

RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://%1.newdomain.com [L]
</VirtualHost>

Is there a way to divert all subdomain names from the old site and
pass it on the the new site keeping the subdomain name intact?

-- Michael

  #2 (permalink)  
Old 09-24-2007
phantom
 
Posts: n/a
Default Re: subdomain pass through

"MWE Computer Services" <MWEComputers@gmail.com> wrote in message
news:1190645619.706242.269750@19g2000hsx.googlegro ups.com...
> Recently we migrated an entire development/internal domain to fully
> qualified external domain name. We have already updated the DNS for
> both the old site to point to our redirect server and new site domain
> location. The problem we have now is that we cannot redirect from the
> old subdomain.domain.com name to the new subdomain.newdomain.com one.
>
> We are running Apache 1.3.37 on HP-UX 11.23 with mod_alias and
> mod_rewrite available.
>
> This is what is needed to happen: site1.domain.com -->
> site1.newdomain.com
>
> I wrote the following out as per our virthosts-redirect.conf file on
> the redirect server:
>
> <VirtualHost redirect.ourdomain.com>
> ServerName domain.com
> ServerAlias www.domain.com
> ServerAlias *.domain.com
> CustomLog /dev/null common
> ErrorLog /dev/null
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]


maybe ([^.]+) should be ([^\.]+)
or, you might just want to remove the rewrite cond completely?

> RewriteRule ^(.*)$ http://%1.newdomain.com [L]


not sure what you're doing here, although %1 should be $1 and unfortunately
the left hand side is only matching on REQUEST_URI (for
http://site1.domain.com/ this will be '/')

> </VirtualHost>
>
> Is there a way to divert all subdomain names from the old site and
> pass it on the the new site keeping the subdomain name intact?
>


A small php script would work, I'm not aware of any way to do this in an
apache 1.3 config.
If you were using apache 2.0.51 or above you could probably use SetEnvIf to
achieve what you are trying to do
http://httpd.apache.org/docs/2.2/mod....html#setenvif


  #3 (permalink)  
Old 09-26-2007
sean dreilinger
 
Posts: n/a
Default Re: subdomain pass through

MWE Computer Services wrote:
> Recently we migrated an entire development/internal domain to fully
> qualified external domain name. We have already updated the DNS for
> both the old site to point to our redirect server and new site domain
> location. The problem we have now is that we cannot redirect from the
> old subdomain.domain.com name to the new subdomain.newdomain.com one.
>
> We are running Apache 1.3.37 on HP-UX 11.23 with mod_alias and
> mod_rewrite available.
>
> This is what is needed to happen: site1.domain.com -->
> site1.newdomain.com


if the "old.com" domain has its own IP address (1.3.5.7) to which all of the
"old.com" websites are pointed, you could use an IP-based virtualhost to catch
and redirect all of the *.old.com traffic, without preconfiguring any serveraliases:

<virtualhost 1.3.5.7>
servername redirect.old.com
rewriteengine on
rewritecond %{HTTP_HOST} ^([^.]+)\.old\.com$ [nocase]
rewriterule ^(.*)$ http://%1.new.com$1 [last, redirect=permanent]
... [ other config requirements - logging, etc. ]
</virtualhost>

if everything, old and new, is stuck pointing at just one ip address that must
be shared among all virtualhosts and both domains, you can skip the separate
redirect host and adjust each virtualhost stanza in the apache configuration to
field traffic for either hostname (old or new)---but redirect guests arriving at
the "old.com" subdomains to the preferred (canonical) hostname immediately.
here's some pseudocode that would apply:

<virtualhost *>
servername sub1.new.com
serveralias sub1.old.com
rewriteengine on
rewritecond %{HTTP_HOST} !^$
rewritecond %{HTTP_HOST} !^sub1\.new\.com [nocase]
rewriterule ^(.*)$ http://sub1.new.com$1 [last, redirect=permanent]
... [ other config requirements - logging, etc. ]
</virtualhost>

<virtualhost *>
servername sub2.new.com
serveralias sub2.old.com
rewriteengine on
rewritecond %{HTTP_HOST} !^$
rewritecond %{HTTP_HOST} !^sub2\.new\.com [nocase]
rewriterule ^(.*)$ http://sub2.new.com$1 [last, redirect=permanent]
... [ other config requirements - logging, etc. ]
</virtualhost>

....

<virtualhost *>
servername subN.new.com
serveralias subN.old.com
rewriteengine on
rewritecond %{HTTP_HOST} !^$
rewritecond %{HTTP_HOST} !^subN\.new\.com [nocase]
rewriterule ^(.*)$ http://subN.new.com$1 [last, redirect=permanent]
... [ other config requirements - logging, etc. ]
</virtualhost>


there is a section in the apache 1.3 url rewriting guide that covers this
scenario, its called "canonical hostnames".
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html

--sean

--
sean dreilinger - http://durak.org/sean/
  #4 (permalink)  
Old 09-26-2007
MWE
 
Posts: n/a
Default Re: subdomain pass through

On Sep 26, 6:09 am, sean dreilinger <sean-use...@durak.org> wrote:
> MWE Computer Services wrote:
> > Recently we migrated an entire development/internal domain to fully
> > qualified external domain name. We have already updated the DNS for
> > both the old site to point to our redirect server and new site domain
> > location. The problem we have now is that we cannot redirect from the
> > old subdomain.domain.com name to the new subdomain.newdomain.com one.

>
> > We are running Apache 1.3.37 on HP-UX 11.23 with mod_alias and
> > mod_rewrite available.

>
> > This is what is needed to happen: site1.domain.com -->
> > site1.newdomain.com

>
> if the "old.com" domain has its own IP address (1.3.5.7) to which all of the
> "old.com" websites are pointed, you could use an IP-based virtualhost to catch
> and redirect all of the *.old.com traffic, without preconfiguring any serveraliases:
>
> <virtualhost 1.3.5.7>
> servername redirect.old.com
> rewriteengine on
> rewritecond %{HTTP_HOST} ^([^.]+)\.old\.com$ [nocase]
> rewriterule ^(.*)$ http://%1.new.com$1 [last, redirect=permanent]
> ... [ other config requirements - logging, etc. ]
> </virtualhost>
>
> if everything, old and new, is stuck pointing at just one ip address that must
> be shared among all virtualhosts and both domains, you can skip the separate
> redirect host and adjust each virtualhost stanza in the apache configuration to
> field traffic for either hostname (old or new)---but redirect guests arriving at
> the "old.com" subdomains to the preferred (canonical) hostname immediately.
> here's some pseudocode that would apply:
>
> <virtualhost *>
> servername sub1.new.com
> serveralias sub1.old.com
> rewriteengine on
> rewritecond %{HTTP_HOST} !^$
> rewritecond %{HTTP_HOST} !^sub1\.new\.com [nocase]
> rewriterule ^(.*)$http://sub1.new.com$1[last, redirect=permanent]
> ... [ other config requirements - logging, etc. ]
> </virtualhost>
>
> <virtualhost *>
> servername sub2.new.com
> serveralias sub2.old.com
> rewriteengine on
> rewritecond %{HTTP_HOST} !^$
> rewritecond %{HTTP_HOST} !^sub2\.new\.com [nocase]
> rewriterule ^(.*)$http://sub2.new.com$1[last, redirect=permanent]
> ... [ other config requirements - logging, etc. ]
> </virtualhost>
>
> ...
>
> <virtualhost *>
> servername subN.new.com
> serveralias subN.old.com
> rewriteengine on
> rewritecond %{HTTP_HOST} !^$
> rewritecond %{HTTP_HOST} !^subN\.new\.com [nocase]
> rewriterule ^(.*)$http://subN.new.com$1[last, redirect=permanent]
> ... [ other config requirements - logging, etc. ]
> </virtualhost>
>
> there is a section in the apache 1.3 url rewriting guide that covers this
> scenario, its called "canonical hostnames".http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
>
> --sean
>
> --
> sean dreilinger -http://durak.org/sean/


This is exactly what I was looking to do. I was able to use the
server's CNS CNAME address, so the first solution worked.

Thanks!

-- Michael


 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:25 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0