gav
gav

Reputation: 29122

PHP Redirect one page to another server without showing URL

Having just written the title for this question I am aware of how dodgy it sounds!

I am writing a back end for storing volunteer information for some friends, they have their own website to which I can add a volunteer.php page.

What I want is for that page to redirect to a page on my server showing the form for the users to fill in, I would prefer the ugly URL of my site not to show.

Is there an easy way to do this? Load the page inside the remotely hosted page somehow?

Thanks,

Gav

Upvotes: 4

Views: 3794

Answers (4)

Tim Lytle
Tim Lytle

Reputation: 17624

mod_rewrite could be used, if their server supports using the [P] (proxy flag):

^/volunteer.php http://yourserver/volunteer.php?id=siteid [P]

Something like that also makes it easy to tell which form you're serving.

Upvotes: 1

Tgr
Tgr

Reputation: 28200

The easy way is to use an iframe, as Josh K said. The elegant way is to generate the form in volunteer.php and have it sent to your server via AJAX so that the visitor never needs to leave their site. Iframes tend to mess up navigation.

Upvotes: 0

Sam Bisbee
Sam Bisbee

Reputation: 4441

I'm assuming that you only want to hide the URL for "ugly URL" reasons, and not security ("what else is on this domain?") or bandwidth reasons). Some possible solutions...

  • Load your form via an iframe. Of course, if the user is at all technically inclined they'll be able to view the iframe's source and get your ugly URL.

  • Use a reverse proxy. This will sufficiently hide your server.

  • Have your application code load in the contents of your remote file, and then output them onto the page. See file_get_contents().

Just remember: do you really want your friends taking up your server's bandwidth?

Upvotes: 1

Josh K
Josh K

Reputation: 28893

You could use an <IFRAME> to show the contents of your sites page without showing the url.

Upvotes: 2

Related Questions