vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Programming Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=188)
-   -   Hotlink Protection Tutorial (Apache Server - .htaccess files) (https://vborg.vbsupport.ru/showthread.php?t=122057)

NeutralizeR 03-21-2008 07:28 AM

Quote:

Originally Posted by attroll (Post 1470463)
My domain is setup so that it works with and without the "www". How can I set it up to with with and without the "www"?

I suggest you to use only one version of your domain with 301 redirect. That way it won't act like two different web sites (bandwidth issue) and hotlink protection'll perfectly work.

attroll 03-21-2008 04:55 PM

Quote:

Originally Posted by NeutralizeR (Post 1470493)
I suggest you to use only one version of your domain with 301 redirect. That way it won't act like two different web sites (bandwidth issue) and hotlink protection'll perfectly work.

I just thought there would be a way to set it up for both in the .htaccess file.

Which would you prefer then, to use "www" and set the 301 redirect for the name witho out hte "www"?

How would I setup a 301 redirect for the one I am not going to use?

NeutralizeR 03-22-2008 06:46 AM

Code:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mysite.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.com$      [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|swf|mp3|mpeg|mpg|ram|rm|wma|wav|asx|wmv|avi|mov|zip|rar|exe)$ http://www.mysite.com [NC,R,L]

Try the one above or this one as the domain line:

Code:

RewriteCond %{HTTP_REFERER} !^http://.*mysite\.com.*$ [NC]

chapsrulez 09-26-2009 08:11 AM

Neutralizer.

thanks for the support.

In my vbulletin configuration i have setup that guests are allowed to vew attachments and i want to keep it that way, and my question is how should i configure the rewrite rule to only limit the access to attachment.php

First i tried with:
PHP Code:

RewriteRule .*\.(php)$ http://www.myserver.com/img/forbid.jpe [R,NC] 

But obviously it locks all the function in vbulletin (login.php, register.php, etc)

Then i tried with:
PHP Code:

RewriteRule attachment.phphttp://www.myserver.com/img/forbid.jpe [R,NC]
RewriteRule .attachment\.(php)$ http://www.myserver.com/img/forbid.jpe [R,NC]
RewriteRule .attach*\.(php)$ http://www.arquinauta.com/img/forbid.jpe [R,NC] 

but none of them seem to work...
thanks again.

final kaoss 03-19-2012 12:06 AM

Thanks but I found a better way to prevent hotlinking. From here.
http://perishablepress.com/creating-...king-strategy/

Code:

###############################
# ultimate hotlink protection #
###############################

# disable directory browsing
# uncomment this option to protect access to directories
# Options -Indexes

# enable the following of symlinks
# uncomment this option if hotlink protection fails to work
# Options +FollowSymLinks

# verify presence of mod rewrite
<IfModule mod_rewrite.c>

 # enable the rewrite engine
 RewriteEngine on

 # check that file exists
 RewriteCond %{REQUEST_FILENAME} -f

 # check for requested file types
 # include additional file types here
 RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$                [NC]

 # allow blank referrer requests
 RewriteCond %{HTTP_REFERER}    !^$

 # allow all requests from your domain
 # edit the domain to match your own
 RewriteCond %{HTTP_REFERER}    !^https?://([^.]+\.)?domain\.      [NC]

 # allow all requests from your ip address
 # edit the ip address to match your own
 RewriteCond %{HTTP_REFERER}    !^https?://123\.123\.123\.123(.*)$ [NC]

 # additional site access
 # include additional sites here replace domain names and or
 # remove unnecessary lines or add new lines for more sites
 RewriteCond %{HTTP_REFERER}    !^https?://([^.]+\.)?domain_01\.  [NC]
 RewriteCond %{HTTP_REFERER}    !^https?://([^.]+\.)?domain_02\.  [NC]
 RewriteCond %{HTTP_REFERER}    !^https?://([^.]+\.)?domain_03\.  [NC]

 # search engine access
 # include or remove search engines feed readers and other sites
 RewriteCond %{HTTP_REFERER}    !search\?q=cache                  [NC]
 RewriteCond %{HTTP_REFERER}    !google\.                          [NC]
 RewriteCond %{HTTP_REFERER}    !yahoo\.                          [NC]

 # allow access to all requests for your anti hotlink image
 # to serve an image instead of delivering a 403 error
 # uncomment the next line and edit the path and file name
 # RewriteCond %{REQUEST_URI}    !^/hotlink\.jpg$                  [NC]

 # deliver the hotlink image for all requests for the listed files
 # protect additional file types by editing the list below
 # if you are serving a file instead of a 403
 # uncomment the next line and edit the path and file name
 # RewriteRule \.(gif|jpe?g?|png)$ http://domain.tld/hotlink.jpg    [R,NC,L]

 # return a 403 error when any of the following file types is requested
 # you can protect additional file types by editing the list below
 RewriteRule \.(gif|jpe?g?|png)$                                  - [F,NC,L]

# close the module container
</ifModule>



All times are GMT. The time now is 11:28 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02174 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete