SunQuest
           Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 10th, 2001, 02:03 AM
forefront forefront is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 165 forefront User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 52 sec
Reputation Power: 9
Redirect domain1.com > domain2.com

A company we are in dispute with over a domain name (domain1.com) points that domain name in their name servers to the IP address of our server where domain2.com is located (we want domain 1.com and domain2.com ultimately to point to the same website)

domain2.com is a virtual host at the IP address so just pointing domain1.com to the IP address results in users coming to oink.com

Without us doing anything to our DNS (another issue) is there a directive at oink.com .htaccess or httpd.conf we can add to send all incoming requests for domain1.com/* to domain2.com/*

Thank you

Reply With Quote
  #2  
Old September 10th, 2001, 03:00 AM
Pushkin Pushkin is offline
Caffeine - Nicotine - Sugar
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Germany, Cologne
Posts: 60 Pushkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Hi, i'm not 100% sure, but i think mod_rewrite will do the trick. Read http://httpd.apache.org/docs/mod/mod_rewrite.html for details.

I once had the same problem but no access to the apache-conf, i solved it with a PHP file. I can hack it for you in 2 minutes if you like.

Reply With Quote
  #3  
Old September 10th, 2001, 06:35 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<VirtualHost *>
...
ServerName domain1.com
...
RewriteEngine on
RewriteRule ^(.*) http://domain2.com$1 [R,L]
</VirtualHost>

This will external redirect all requests of http://domain1.com to http://domain2.com.

>> Without us doing anything to our DNS (another issue)

If your DNS server is authoratitive for domain1.com, it's as simple as adding an A record and adding a ServerAlias domain1.com to httpd.conf on your domain2.com. No redirection needs to be done at all.

Reply With Quote
  #4  
Old September 10th, 2001, 07:17 AM
forefront forefront is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 165 forefront User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 52 sec
Reputation Power: 9
I cannot change anything in our DNS so added the following (exactly) to htttpd.conf

<VirtualHost *>
ServerName domain1.com
RewriteEngine on
RewriteRule ^(.*) http://domain2.com$1 [R,L]
</VirtualHost>

Restarted Apache and there is no difference when calling up domain1.com

Also tried:

<VirtualHost domain1.com>
ServerName domain1.com
ServerAlias www.domain1.com
RewriteEngine on
RewriteRule ^(.*) http://domain2.com$1 [R,L]
</VirtualHost>

Can one just add a new VirtualHost to httpd.conf without there being a corresponding DNS entry?

Thanks

Reply With Quote
  #5  
Old September 10th, 2001, 08:04 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> Restarted Apache and there is no difference when calling up domain1.com

The minimum number of line requirement are:

ServerName domain1.com
RewriteEngine on
RewriteRule ^(.*) http://domain2.com$1 [R,L]

within that <VirtualHost> block. You don't even need to set a docroot there.
Make sure you are doing this on domain1.com, not domain2.com.

>> without there being a corresponding DNS entry?

What DNS entry? BTW, do you have any priviledge on domain1.com at all? If not, just give it up as it won't work at all.

Reply With Quote
  #6  
Old September 11th, 2001, 02:58 AM
forefront forefront is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 165 forefront User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 52 sec
Reputation Power: 9
Quote:
BTW, do you have any priviledge on domain1.com at all? If not, just give it up as it won't work at all.


We have no control over domain1.com - as I stated, domain1.com is being pointed to an IP address where domain2.com is located as a virtual host.

When someone types in domain1.com they get oink.com as that is the "primary" host at the IP address in question.

We DO have full control over oink.com but we do not want all requests to oink.com to be directed to domain2.com - just those with domain1.com as the requested domain.

We are already using Mod_Rewrite at oink.com - is there a second rewrite rule (before the existing one?) we can add within the httpd.conf enty for oink.com so that incoming requests to oink.com where the requested domain is domain1.com are redirected to domain2.com?

Thank you

Reply With Quote
  #7  
Old September 11th, 2001, 07:14 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If I understand correctly, oink.com is the default server and domain2.com is a vhost with the same IP as oink.com. domain1.com is not a vhost but it's resolvable to the same IP as oink.com?

If that's the case, do this in httpd.conf on oink.com:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ [NC]
RewriteRule ^(.*) http://domain2.com$1 [R,L]

If oink.com is defined within <VirtualHost>, put those rewrite lines within it. Else put those globally and give them lower priority by placing them at the bottom of httpd.conf.

Reply With Quote
  #8  
Old September 11th, 2001, 08:50 AM
forefront forefront is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 165 forefront User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 55 m 52 sec
Reputation Power: 9
Perfect, thank you - I just repeated the rule a second time to catch those who miss out the "www" on domain1.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Redirect domain1.com > domain2.com


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway