Navneet Pandey
Navneet Pandey

Reputation: 133

Redirect to url then again redirect to main url

I know it is really confusing. Let me explain:

I want to open the urls on my site (http://domain.com) to a (http://domain.com/url='the submitted url') and then the submitted url is opened.

Eg: When we open any other site link from Google+ let the example

http://www.youtube.com/watch?v=WRpX7tkwejU

it redirects to

http://plus.url.google.com/url?sa=z&n=1333340186022&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWRpX7tkwejU&usg=whZv4BO7Gcrco_vivlnhaz27Wpk.

and then the original site is opened. I want some thing similar.

Upvotes: 0

Views: 196

Answers (1)

deceze
deceze

Reputation: 522461

  1. On your site, replace any regular external link like http://example.com with, say, /redirect.php?url=http%3A%2F%2Fexample.com. Make sure to urlencode the original domain name.
  2. In redirect.php, redirect the user:

    header('Location: ' . $_GET['url']);
    

Upvotes: 3

Related Questions