|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
<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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
>> 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. |
|
#6
|
|||
|
|||
|
Quote:
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 |
|
#7
|
|||
|
|||
|
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. |
|
#8
|
|||
|
|||
|
Perfect, thank you - I just repeated the rule a second time to catch those who miss out the "www" on domain1.com
|
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Redirect domain1.com > domain2.com |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|