tags:

views:

35

answers:

3

Does any of you know how to mask a URL in php?? Like the one you see in free URL redirectional services (http://www.shorturl.com)

I mean I have a url like http://www.my-server.com/

which will redirect me to http://www.some-other-server.com/abc.php

But I want the URL in the address bar of my browser to show only this URL

http://www.my-server.com/

Is this possible??

Thanks in Advance...

+1  A: 

Use url-rewriting via e.g. mod_rewrite.

Edit: won't work cross server, I forgot.
Then link your domain to the other server using the DNS-entry.

alopix
That won't work across servers
David Dorward
Linking via DNS won't work if the other server uses virtual name hosting (which is very likely unless it is a huge site). It also won't let you change the local part of the URI, so http://www.my-server.com/ would go to http://www.some-other-server.com/ instead of http://www.some-other-server.com/abc.php
David Dorward
What the heck? Why shouldn't he be able to add his domain to the other server/webspace? Almost every provider supports that.
alopix
Oh, you meant an normal A record rather than a redirect? The question implied the other domain wasn't under the control of the OP (given the discussion of shorturl services being similar to what was wanted) so virtual name hosting would fail if you tried that.
David Dorward
A: 

The two options are to:

  1. Copy the data from the destination URL to the URL you want it to appear on
  2. Frames — which have horrible drawbacks and don't stop a user finding out what the real URI is in a click or two.

Trying to disguise a URI while letting a user access it is Not A Good Idea (TM).

David Dorward
Do you really think he want's to disguise the URI? More than 1 Domain seems more likely.
alopix
He said "But I want the URL in the address bar of my browser to show only this URL" — so, yes, I do. The motivations might not be to deceive, but that task is the same.
David Dorward
Maybe he only wants the abc.php as index for the second domain. He didn't state that the whole site should only show this domain.
alopix
A: 

You could run nginx or apache in reverse proxy mode on www.my-server.com, and configure it to forward requests to www.my-other-domain.com. If both domains are hosted on the same network, it'll be tolerable. If they are hosted on different networks, the bandwidth waste might be awful.

sarnold