phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
Hotlinking / Help

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB mod Rewrite
::  
Author Message
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Fri Oct 13, 2006 7:59 am    Post subject: Hotlinking / Help

Following your advice from here:

http://boards.phpbb-seo.com/phpbb-mod-rewrite/discussions-vt302.html


I have now tried the following as you stated. This is with the advanced code for SEO. Now PHPBB will not work. When I do this I get a code 500 internal server error.

What now? Embarassed




Code:
# These three lines should only be added if not already done in the .htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_REFERER} !^$ [AND]
RewriteCond %{HTTP_REFERER} !^http://mydomain.net/.*$ [NC, AND]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.net/.*$ [NC]
ReWriteRule .*\.(rar|zip|jpe?g)$ - [F,L]

#########################################################
# forum SEO REWRITE RULES            #
#########################################################
# AUTHOR : DCZ http://www.forum-seo.com/
# STARTED : 01/2006
#####################################################
#



ETC ETC ETC
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Fri Oct 13, 2006 10:26 am    Post subject: Re: Hotlinking / Help

hum,

And what about this :

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www\.mydomain\.net/.*$ [NC]
ReWriteRule .*\.(rar|zip|jpe?g)$ - [F,L]


As a first try.

The www prefix matter should be dealt with before, so you don't really need to re check it here.

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Fri Oct 13, 2006 11:41 am    Post subject: Re: Hotlinking / Help

http://www.inetbridge.net/forum/download.php?id=375

If you can download that file off here by clicking on it then that one did not work.

I am lost in space. Very Happy
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Sat Oct 14, 2006 6:45 pm    Post subject: Re: Hotlinking / Help

Oh I see, we do not deal with images here, but with downloads.

So this should be done php wise in download.php after the var grabbing and before the work, following the same principle. 1) check if HTTP_REFERER is not empty then check if it's not yours and if not deny or do whatever.

Code:
if ( !empty($_SERVER['HTTP_REFERER']) && !strpos($_SERVER['HTTP_REFERER'], 'www.example.com') ) {
     // Deny the download, could load a custom page from here
     ............
}


++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Sun Oct 15, 2006 1:46 am    Post subject: Re: Hotlinking / Help

dcz wrote:
after the var grabbing and before the work



Where in the code would that be? I have no idea what you are saying.
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Sun Oct 15, 2006 10:37 am    Post subject: Re: Hotlinking / Help

Could you post the first 50 lines of code from you download.php file, or a link to a zip of it ?

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Sun Oct 15, 2006 12:24 pm    Post subject: Re: Hotlinking / Help

Code:
<?php
/**
*
* @package attachment_mod
* @version $Id: download.php,v 1.6 2006/09/04 12:56:06 acydburn Exp $
* @copyright (c) 2002 Meik Sievertsen
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/


      $browser_version = $log_version[1];
      $browser_agent = 'konqueror';
   }
   else
   {
      $browser_version = 0;
      $browser_agent = 'other';
   }


Last edited by AMH on Wed Oct 18, 2006 9:36 am; edited 1 time in total
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Sun Oct 15, 2006 1:49 pm    Post subject: Re: Hotlinking / Help

As it's within phpbb sessions, you can put this after :

Code:
include($phpbb_root_path . 'common.' . $phpEx);


Don't forget you need to decide what to do, you could for example do this to simply deny the loading :
Code:

if ( !empty($_SERVER['HTTP_REFERER']) && !strpos($_SERVER['HTTP_REFERER'], 'www.example.com') ) {
      if ( !empty($db) ) {
         $db->sql_close();
      }
      exit();
}


or use message_die(GENERAL_MESSAGE, 'yourmessage'); to output a nice message instead Wink

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Sun Oct 15, 2006 3:27 pm    Post subject: Re: Hotlinking / Help

Thankyou!


You are brilliant! Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy


One last "small" problem.

On a webpage as on this one it blocks the download. BUT if you copy the url into the browser, it still downloads. Is that normal?
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Sun Oct 15, 2006 5:10 pm    Post subject: Re: Hotlinking / Help

You're welcome Wink

Well yes, because in this cas the http referer will be empty. If you do not allow empty http referer you take the risk to deny download for user of your website behind firewalls, as the http referer could be blocked by the firewall settings.

But this is not this big of a deal to allow empty http referer as you filter most people who followed a download link from another web site, unless again behind a firewall.

I don't think people copying and pasting URL into the browser would end up being many.

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Mon Oct 16, 2006 1:57 am    Post subject: Re: Hotlinking / Help

Thanks again! Very Happy
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Mon Oct 16, 2006 10:41 am    Post subject: Re: Hotlinking / Help

Wink

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Sat Sep 01, 2007 9:45 am    Post subject: Re: Hotlinking / Help

Its taken a while to figure why my bandwidth is going skyward again. It appears that the solution here does not work. Users can still right click on the sites and download from my site.

EG:

I have a scraper site that is leaching my bandwidth by a few GB a day.

<scraper site>


If you click on the link on the above page - Yes, it does do what this threads says it will do however if you right click and download it can still steal bandwidth.

Is there any way to fix this? Rolling Eyes


Last edited by AMH on Sat Sep 01, 2007 10:26 am; edited 2 times in total
Back to top
AMH



Joined: 11 Oct 2006
Posts: 30

Hotlinking / HelpPosted: Sat Sep 01, 2007 10:25 am    Post subject: Re: Hotlinking / Help

Very Happy Very Happy

I found the solution and itt might be useful to others! Oh, I get to contribute. Might limit damage from these scraper sites!



Keep people from hotlinking your attachments

Create an .htaccess file with this code and drop it in your files directory

Arrow

SetEnvIfNoCase Referer "http://www.yourdomain.com" locally_linked=1
SetEnvIfNoCase Referer "http://yourdomain.com" locally_linked=1
<FilesMatch "\.*$">
Order Allow,Deny
Allow from env=locally_linked
</FilesMatch>


Arrow Open download.php


Arrow Find:

readfile($filename);


Arrow Replace with:

header("Location: $filename");
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 13994

Hotlinking / HelpPosted: Sun Sep 02, 2007 3:03 pm    Post subject: Re: Hotlinking / Help

Thanks for sharing Wink

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB mod Rewrite
Page 1 of 1

Navigation

Jump to: