Results 1 to 8 of 8

.htaccess for hotlink protection

This is a discussion on .htaccess for hotlink protection within the General Discussion forums, part of the vBulletin SEO Discussion category; I want to enable hotlink protection for my server. I was thinking of enabling it from cPanel but since i ...

  1. #1
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    22,367
    Liked
    542 times
    Blog Entries
    4

    .htaccess for hotlink protection

    I want to enable hotlink protection for my server. I was thinking of enabling it from cPanel but since i currently have a .htaccess it may mess with my vbseo settings.

    Is the following .htaccess correct ? and do you advice me to change any settings ?

    Code:
    # Comment the following line (add '#' at the beginning)
    # to disable mod_rewrite functions.
    # Please note: you still need to disable the hack in
    # the vBSEO control panel to stop url rewrites.
    RewriteEngine On
    
    # Some servers require the Rewritebase directive to be
    # enabled (remove '#' at the beginning to activate)
    # Please note: when enabled, you must include the path
    # to your root vB folder (i.e. RewriteBase /forums)
    
    RewriteRule ^(sitemap.*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} (admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.*)$ $1 [L]
    
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_FILENAME} !chat
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://ayyas.com.*$     [NC]
    RewriteCond %{HTTP_REFERER} !^http://www.ayyas.com.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://october.ayyas.com.*$ [NC]
    RewriteRule .*\.(gif|GIF|jpg|JPG|mpg|MPG|wmv|WMV|jpeg|JPEG|avi|AVI|rar|RAR|zip|ZIP)$        http://www.ayyas.com/images/warning.gif                  [L,R]
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  2. #2
    Senior Member
    Real Name
    Keith Cohen
    Join Date
    Jul 2005
    Location
    Raleigh, NC USA
    Posts
    6,147
    Liked
    12 times
    Add your warning image in too, or it could get into a loop I think.

    Here's what I use:

    Code:
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://.*fireblades\.org.*$ [NC] 
    RewriteCond %{HTTP_REFERER} !^https://.*fireblades\.org.*$ [NC] 
    RewriteCond %{REQUEST_URI}  !^.*leech\.gif$ [NC]
    RewriteRule ^.*\.(swf|bmp|gif|jpg|png|jpeg|avi|wmv|mpg|mpeg|wav|mp3)$ http://www.fireblades.org/images/leech.gif [NC,R,L]

  3. #3
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    22,367
    Liked
    542 times
    Blog Entries
    4
    Thanks
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  4. #4
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    22,367
    Liked
    542 times
    Blog Entries
    4
    Conqsoft i placed this .htaccess in my public_html dir which is as same as my forum dir but this doesn't effect the folders like public_html/galeri/ i had to manually add this to the folders i wanted to get protected.

    This is the whole .htaccess i have in my public_html

    Code:
    RewriteEngine On
    RewriteRule ^(sitemap.*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    RewriteCond %{REQUEST_FILENAME} (admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.*)$ $1 [L]
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_FILENAME} !chat
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://.*ayyas\.com.*$ [NC] 
    RewriteCond %{HTTP_REFERER} !^https://.*ayyas\.com.*$ [NC] 
    RewriteCond %{REQUEST_URI}  !^.*warning\.gif$ [NC]
    RewriteRule ^.*\.(swf|bmp|gif|jpg|png|jpeg|avi|wmv|mpg|mpeg|wav|mp3|rar|zip|JPG|GIF|Jpg|RAR|ZIP|Rar|Zip])$ http://www.ayyas.com/images/warning.gif [NC,R,L]
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  5. #5
    Member Eros's Avatar
    Real Name
    Eros
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    51
    Liked
    0 times
    is there any way to exclude any specific domain ? like only mysite.com can hotlink all the contents frm mysite.org, but any other sites cant..

  6. #6
    vBSEO Staff Ace Shattock's Avatar
    Real Name
    Ace Shattock
    Join Date
    Jul 2005
    Location
    Auckland, New Zealand, New Zealand
    Posts
    3,998
    Liked
    11 times
    Quote Originally Posted by Lizard King
    Conqsoft i placed this .htaccess in my public_html dir which is as same as my forum dir but this doesn't effect the folders like public_html/galeri/ i had to manually add this to the folders i wanted to get protected.

    This is the whole .htaccess i have in my public_html

    Code:
    RewriteEngine On
    RewriteRule ^(sitemap.*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    RewriteCond %{REQUEST_FILENAME} (admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.*)$ $1 [L]
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_FILENAME} !chat
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://.*ayyas\.com.*$ [NC] 
    RewriteCond %{HTTP_REFERER} !^https://.*ayyas\.com.*$ [NC] 
    RewriteCond %{REQUEST_URI}  !^.*warning\.gif$ [NC]
    RewriteRule ^.*\.(swf|bmp|gif|jpg|png|jpeg|avi|wmv|mpg|mpeg|wav|mp3|rar|zip|JPG|GIF|Jpg|RAR|ZIP|Rar|Zip])$ http://www.ayyas.com/images/warning.gif [NC,R,L]
    Do you have .htaccess files in the /galleri/ directory?

    (Before adding the code to them I mean)...

  7. #7
    Member atlanticangler's Avatar
    Real Name
    Sam
    Join Date
    Nov 2006
    Posts
    69
    Liked
    0 times
    This is what I am trying as my .htaccess file in my forum directory and it is not working. Any ideas?

    Code:
    # Comment the following line (add '#' at the beginning)
    # to disable mod_rewrite functions.
    # Please note: you still need to disable the hack in
    # the vBSEO control panel to stop url rewrites.
    RewriteEngine On
    
    # Some servers require the Rewritebase directive to be
    # enabled (remove '#' at the beginning to activate)
    # Please note: when enabled, you must include the path
    # to your root vB folder (i.e. RewriteBase /forums)
    #RewriteBase /
    
    #RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com
    #RewriteRule (.*) http://www.yourdomain.com/forums/$1 [L,R=301]
    
    RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    
    RewriteCond %{QUERY_STRING} !vbseourl=
    RewriteCond %{REQUEST_FILENAME} !(admincp/|modcp/|chat|cron)
    RewriteRule ^(.*\.php)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{REQUEST_FILENAME} !\.(jpg|gif)$
    RewriteRule ^(archive/.*)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !(admincp|modcp|clientscript|cpstyles|images)/
    RewriteRule ^(.+)$ vbseo.php?vbseourl=$1&%{QUERY_STRING} [L]
    
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://.*atlanticanglers\.com.*$ [NC] 
    RewriteCond %{HTTP_REFERER} !^https://.*atlanticanglers\.com.*$ [NC] 
    RewriteCond %{REQUEST_URI}  !^.*leech\.gif$ [NC]
    RewriteRule ^.*\.(swf|bmp|gif|jpg|png|jpeg|avi|wmv|mpg|mpeg|wav|mp3)$ http://www.atlanticanglers.com/images/leech.gif [NC,R,L]
    Sam- AtlanticAnglers.com

  8. #8
    Member atlanticangler's Avatar
    Real Name
    Sam
    Join Date
    Nov 2006
    Posts
    69
    Liked
    0 times
    Okay, I put the same .htaccess file in the root directory and it worked fine with the rest of the site, but the forum doesn't seem to be working.
    Sam- AtlanticAnglers.com

Similar Threads

  1. Add "www." in .htaccess
    By Jason|Xoxide in forum Custom Rewrite Rules
    Replies: 8
    Last Post: 03-31-2006, 12:54 PM
  2. Internal 500 Error -- problem with .htaccess
    By ADM in forum Troubleshooting
    Replies: 6
    Last Post: 10-11-2005, 06:08 PM
  3. .htaccess
    By Keith Cohen in forum General Discussion
    Replies: 2
    Last Post: 10-07-2005, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •