Save Tons Of Bandwidth On Your Proxy Site
#1
Posted 14 May 2006 - 10:44 PM
$domain="proxywebsite.com"; // insert your domain name here, NO www.!!!
$referer=$_SERVER['HTTP_REFERER'];
$count=substr_count($referer,$domain);
if($referer!="" && $count==0){
if($HTTP_GET_VARS['q']!="" && $HTTP_GET_VARS['hl']==""){
header("Location: http://" . $domain . "/");
exit();
}
}
The code checks to see if there is only an object (image, swf etc) being requested by a referer that is not your site. If it finds that an only an object is being requested, and no html, it will redirect straight to the homepage of your site. This prevents any files being hotlinked!
#2
Posted 18 May 2006 - 09:51 PM
#3
Posted 19 May 2006 - 03:18 AM
And you say that if only an image is requested, it will redirect the user to my index again. Do you then mean that if I insert this code in my index.php, and somebody try to access the folder "damdidam/myimage.jpg", they will be redirected to index.php?
Iīm such a noob
#4
Posted 30 May 2006 - 03:11 PM
Ok in the main index.php of your site insert this right after the "<?php" tag to save loads of bandwidth.
$domain="proxywebsite.com"; // insert your domain name here, NO www.!!!
$referer=$_SERVER['HTTP_REFERER'];
$count=substr_count($referer,$domain);
if($referer!="" && $count==0){
if($HTTP_GET_VARS['q']!="" && $HTTP_GET_VARS['hl']==""){
header("Location: http://" . $domain . "/");
exit();
}
}
The code checks to see if there is only an object (image, swf etc) being requested by a referer that is not your site. If it finds that an only an object is being requested, and no html, it will redirect straight to the homepage of your site. This prevents any files being hotlinked!
How would this differ from doing it in .htaccess?
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?dorkytutorial\.com [NC] RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]
#5
Posted 02 September 2006 - 08:36 AM
Edited by itunes66, 02 September 2006 - 08:37 AM.
#6 _*Lewisthemusician_*
Posted 27 December 2006 - 07:06 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users