Redirect a user to an external site while linking to an internal page?

How can I redirect a user to an external site while linking to an internal page ?

I have seen examples like:

  • ... And many more...

How this is achieved in php ?

Does this have any pros/cons with regards to SEO ?


I don't see any benefit in this approach, but there are a few ways to achieve it. To do it with the GET query, you would simply need the following code:

  <a href="">Google!</a>
if (filter_var($_GET['site'], FILTER_VALIDATE_URL)) {
          header('Location: ' . $_GET['site']);

With the above example, it will actually take the user to that location, not to:

To achieve the url being "local" while pulling up a remote site, you'd either have to:

  • Mess with URL rewriting, which can get messy and I'm not sure will let you do the above
  • Retrieve the remote page via curl and display it, which may screw up links on the "remote" page
  • Use iframes and set the iframe to be the size of the page. Note that this last method, while least offensive, is recognized as a potential security breach known as 'clickjacking' since it's used to trick users into clicking on a link for one page which his hiding a malicious link to another site. Many servers and browsers are taking steps to avoid this (for instance, google does not allow iframing of its home page), so this may also reach dead ends.

So of the three server-side methods I can think up, one may or may not be possible, and is a pain. One will be crippled and put a heavy load on the server. The last is a known bad guy and is likely not to work for many cases.

So I'd just go with a redirect, and really, if you don't need the address bar to show the local URL, then I'd just have a direct link.

All of the raises the question: What are you hoping to accomplish?

Set up an index php file which sets the header location to the url in the get parameter. :

if (isset($_GET['go'])) {
    $go = $_GET['go'];
    header('Location: $go');
} // else if other commands
// else (no command) load regular page
?> :


you can use iframe and set the src attribute to



   <iframe src="" width="100%" height="100%"></iframe>


put this is beginning before any output to browser


I use .htaccess rules for this. No PHP needed.


Redirect 307 /go/somewhere-else

So visiting will redirect to

On my site, I use "nofollow" to tell the search engines not to follow the link. The 307 status code means "temporary redirect".

<a href="" rel="nofollow">Click here!</a>

Need Your Help

Cypher Query to get duplicate(same id) relationship between nodes

neo4j cypher

I have city nodes connected to each other by HAS_BUS relationships.

WSO2: API Manager; calling publish api from webservice

wso2 wso2carbon

Is it possible to call the WSO2 API Manager:: publisher api, as described in: