Link to home
Start Free TrialLog in
Avatar of matiascx
matiascxFlag for China

asked on

How to implement a server serves following: a.com -->b.com/xx

Dear Experts,
We have following requirement:
When user surf the www.a.com , he will be redirected to www.b.com/xxx , how to implement that on the a.com and b.com servers?
Can you help to give some information meeting above requirement?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Beneford
Beneford
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of matiascx

ASKER

Dear Beneford,
If i am not happy if user knows www.a.com is www.b.com/xx how to do that?

Best Regards,
Robert
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dear Beneford,
The www.a.com and www.b.com are totally two linux servers on the internet in different countries.
I have totally controlled on them.
Please give more detail info on how to implement that requirement.
I want the www.a.com looks as www.a.com , but the content is www.b.com/xxxx

Thanks!
Avatar of giltjr
Do you plan on using www.a.com for anything?  From what it sounds like no.

So on the server that is currently hosting www.b.com, setup a named virtual host of www.a.com with a documentroot that points to /xxxx.  Change the dns entry for www.a.com to point to the IP address of www.b.com and then you no longer need the server running www.a.com.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Although you can do it setting up Apache as a reverse proxy server.  My question would be why?

If you want www.a.com to really show www.b.com/xxxx.  Why not just make www.a.com a virtual server on the same box as www.b.com?

In simpler terms, why make two hops when you can have one?
@giltjr,
The requirement is: in our country, not registered domain , such as a.com can not be pointed to server who hosting b.com(b.com has been registered by government).
Meanwhile, the register process is very long, i am not happy on this process!
In that case using Apache as a proxy server, as Beneford,  stated would work.

However, in reality you would not be pointing to b.com, you would be pointing to an IP address.  It would just happen to match the address that is being used by another host name.

However, either way if there is some law within your country you could be in violation anyway.

Do you control the server that hosts b.com?  If so, there are some methods of mirroring so that you leave a.com and b.com independent, but they are exactly the same.  If you don't control b.com, then there could be other legal issues.
There is no legal issue. Just because the process is very long and money consuming, so we setup this service for limited users. Meanwhile, we will continue to register a.com.
Dear Beneford,
What do you mean the "Web Forwarding"?
How can i implement that?

Best Regards,
Robert
Avatar of skullnobrains
skullnobrains

on host A, use this

proxyPass / www.b.com/xxx/

beware that your traffic will transit through both servers

---

another quick and dirty way is to serve an frameset on www.a.com that will only contain a single frame with it's source on www.b.com. ugly, and easy to see that the server is in a different place, but functionnal
Um, if there is no legale issue, then just change the A record for www.a.com to point to the IP address of the host where "b.com" is hosted.  In fact remove the a record for www.a.com and make it a CNAME that points to www.b.com.  That way if the IP address of www.b.com ever changes you don't need to do anything with www.a.com.

You can leave the domain name a.com registered just as it is today.  How/where a domain name is registered and what IP address a host name points to are two totally different things.
@giltjr,
As i stated above, i can not point my a.com A record to the IP who hosting the b.com currently. Otherwise, the ISP will close down the server who is hosting b.com.
As you said, if just make a CNAME pointing to b.com, how can i implement: a.com=b.com/xxx ?
Please note in mind that: b.com server can not serves any request on behalf of a.com domain.

BR/Robert
- if your isp won't let you create an A record, there is no way he'll let you create a CNAME
- there is also no way to redirect to a subdirectory, but i guess you can make it work with a virtual host instead of a subdirectory

what is wrong with proxyPass ?
note that if you're afraid that internal links may break or visually redirect the user to the other server, apache can be instructed to rewrite them (ie take all links in the page that point to b.com/xxx and change them to a.com automagically). don't play with that before you checked that you need to
How would the ISP know?  In order to do that it would need to do one of the following:

1) Know you have another domain called a.com and monitor every A/CNAME in that domain for changes.
2) Monitor each and every packet coming into your b.com server and look for host names other than b.com.
3) Look at your Apache configuration for host names other than b.com.

If the ISP is doing that, get another ISP.  They should not care what host names you have pointing to that server's IP address.
i thought it hosted the DNS so it would know easily, but anyway the problem is exactly the same with an A or a CNAME record.

the setup is very unclear and i'm getting annoyed that we do not have any REAL information and not even the name of the country.
Not sure what you mean by "it hosted the DNS."  What is "it?"

Nothing would know that you have a host name called "www.a.com" that points to the IP address of the server that also has a host name of "www.b.com" unless somebody was specifically looking for it.

Heck, I could add a host name called "somehost.mydomain.com" that points to the IP address of your www.a.com and the ISP hosting www.a.com would never know.  In fact you may never even know.

To find out where the server MIGHT be hosted, you might be able to use whois and look up the IP address of the server.
i thought A was the FAI hosting the DNS

what you say above is mostly correct, but the fact remains that if creating an A record would be detected and forbidden, creating a CNAME instead will not make much of a difference.

and actually, if B is an ISP, then it most likely makes use of name based virtualhosts, so it probably would not work at all and be very quickly detected if the logs are properly monitored (which is unlikely, i must admit).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't want to argue either.  No hard feelings.  

But I'm not sure what you mean by a hypothetical situation.  Do you mean what the author's request it?  I will say something does seem a bit fishy.

If I am in charge of a web server with IP address x.x.x.x and I am in control of domain "mydominan.com"  I can setup a A record in that domain pointing to that IP address.  It should not matter who is providing the DNS server service or who is providing the web server service.
ok :)

yes i'm talking about the request : what is a "registered" domain in his world ? why would he hide the country he is in ? .... either he is doing barely legal stuff somewhere and would not say so, or he is a secret-freak.

i also read other questions, and i believe he's relying on other people to do quick and dirty money using technologies he usually does not have the first clue about, and would rather take a LOT of other people's time by hiding his real goals and asking unclear questions with insufficient background to understand the answers rather than try and be honest, and do a little reading before asking.

over and out
Your right.  Looks like he is attempting to provide a "questionable" service.  Even if it is legit, he is in way over his head.