Hotlinking using station/redirect.php page

Post Reply
User avatar
polbrieuc
Advisor
Advisor
Posts: 98
Joined: Wed Dec 06, 2017 10:58 pm
Location: Vallirana
Station model: WH1080
Software: Cumulus
Contact:

Hotlinking using station/redirect.php page

Post by polbrieuc » Fri Nov 29, 2019 11:37 am

Hello,

I recently saw an increase in traffic (in Google Analytics and in my logs) on my MT site and discovered that some external sites are using one of the meteotemplate pages to redirect their users to different websites.

My first to option was to kill the visit but then I thought there was no harm in just redirecting them to the homepage of my site.
I added the following code before the html tag of the pages/station/redirect.php file and it looks like it is working as expected :

Code: Select all

<?php
// This is to check if the request is coming from a specific domain
$ref = $_SERVER['HTTP_REFERER'];
$refData = parse_url($ref);
if($refData['host'] == 'cerrajerosgasteiz.com') {		// replace by the offender website 			
   //die("Hotlinking not permitted");
  $address ="https://elspinars.es/"; // replace by your own domain name
}
?>
Another option would have been to restrict access to this page to visitors already browsing my site (so whitelisting my site instead of blacklisting the offender site) but it may prevent direct external linking to the station data.

Cheers,

Pol-Brieuc
Image

Post Reply