Jump to content


Photo
- - - - -

Save Tons Of Bandwidth On Your Proxy Site


  • Please log in to reply
5 replies to this topic

#1 proxinated

proxinated

    Young Padawan

  • Members
  • Pip
  • 14 posts
  • Location:Pickens, SC
  • Interests:♥♥♥ Ashley McCall ♥♥♥

Posted 14 May 2006 - 10:44 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!

#2 Ben

Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

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 Indigo

Indigo

    Official Alien

  • Members
  • PipPipPip
  • 617 posts
  • Gender:Male
  • Location:Trondheim, Norway
  • Interests:Computing in general, especially design and programming of all kinds.

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 :D

#4 Hayden

Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 717 posts
  • Gender:Male
  • Location:Texas

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 Jordan Pittman

Jordan Pittman

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 56 posts
  • Gender:Male

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_*

_*Lewisthemusician_*
  • Guests

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users