RSS collection with redirection - and lots of Google-clicks

The Norwegian site (collection of RSS-feeds) uses redirection on all articles.

If you enter an article from you will be redirected to original source, but from Google (or typing URL directly in the address bar) you will not be redirected. How can this be done? With .htaccess or php? Is it legal?

Info from Google: -> 7 380 000 results.

I found the answer :slight_smile:

nyheter/side1.php - with link
artikkel/side2.php - redirection
side3.php -with link

//Code ‘side1.php’
<a href=“…/artikkel/side2.php”>Side2</a>

//Code ‘side2.php’
$referer = $_SERVER[‘HTTP_REFERER’];
if (preg_match(“/nyheter/”,$referer)) {

//Code ‘side3.php’
<a href=“artikkel/side2.php”>Side2</a>