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!
Save Tons Of Bandwidth On Your Proxy Site
Started by proxinated, May 14 2006 10:44 PM
5 replies to this topic
#1
Posted 14 May 2006 - 10:44 PM
#2
Posted 18 May 2006 - 09:51 PM
Thankyou for sharing this! Ive been hosting a private proxy server for school, but word got out and now everyones using it. I did have a problem with bandwidth. So thanks =D
#3
Posted 19 May 2006 - 03:18 AM
I still donīt quite get how this will save me lots of bandwidth, can you explain?
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
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
proxinated, on May 15 2006, 03:43 AM, said:
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!
$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
.htaccess is better, because the requests would have to be going through the index.php page on the code he/she gave
Edited by itunes66, 02 September 2006 - 08:37 AM.
#6 _*Lewisthemusician_*
Posted 27 December 2006 - 07:06 AM
Thanks, i needed this, i use free hosting with like hardly any bandwidth so this would be handy.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
