FreePgs.com Forum
December 07, 2021, 01:32:20 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The "Support Requests" forum is now viewable by guests.
 
   Home   Help Search Login Register  
Pages: 1 2 [3]   Go Down
  Print  
Author Topic: htaccess  (Read 28587 times)
webzone (archived)
Official Technical Support
Verified Account
Hero Member
*

Karma: +0/-0
Offline Offline

Posts: 508

Archived Account

Blog entries (0)

View Profile
« Reply #30 on: November 30, 2005, 11:25:20 PM »

adding extensions to the .htaccess protection won't cause a problem. this time, i tested it.

but i still can't seem to get the code allowing multiple referer domains to work as intended.
Logged
admin
Administrator
Hero Member
*****

Karma: +30/-2
Offline Offline

Posts: 1567

Blog entries (0)

View Profile
« Reply #31 on: December 01, 2005, 02:00:16 AM »

This is typically because you do not have the correct flags at the end of the rules or conditions (in []) to specify if this is the last rule, etc.

Please see http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html for more information.  You may need to use [OR] on the RewriteCond lines for example.

Thank you,
FreePgs.com Admin
Logged
FreePgs.com Forum
« Reply #31 on: December 01, 2005, 02:00:16 AM »

 Logged
markjay
Verified Account
Full Member
*

Karma: +3/-0
Offline Offline

Posts: 165


Blog entries (0)

View Profile WWW
« Reply #32 on: December 01, 2005, 07:11:30 AM »

Example: Your site url is www.example.com. To stop hotlinking images from an outside domain and display an image called nohotlink.jpg instead, use this code in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]

To allow hotlinking images only if the REFERER (sic) is from a specific directory from your domain:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/dir/ [NC
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]

To stop hotlinking images from specific outside domains only, named badsite.net and badsite.com:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.net/ [NC,OR
RewriteCond %{HTTP_REFERER} ^http://(www\.)?badsite\.com/ [NC
RewriteRule \.(jpe?g|gif|bmp|png)$ images/nohotlink.jpg [L]

Limit bandwidth usage by returning a 403 forbidden code. Replace the last line of the previous examples with this line:
RewriteRule \.(jpe?g|gif|bmp|png)$ - [F]

Warning: Do not use .htaccess to redirect image hotlinks to another HTML page or server that isn't your own (such as this web page). Hotlinked images can only be redirected to other images, not to HTML pages.

As with any .htaccess rewrites, you may block some legitimate traffic (such as users behind proxies or privacy firewalls) using these techniques.

source: http://altlab.com/htaccess_tutorial.html
Logged

webzone (archived)
Official Technical Support
Verified Account
Hero Member
*

Karma: +0/-0
Offline Offline

Posts: 508

Archived Account

Blog entries (0)

View Profile
« Reply #33 on: December 01, 2005, 03:43:41 PM »

The two first examples mostly come to the exact same thing that the code I provided does. In fact, my code is mostly a compressed version of this.

By the way, there are many missing ] in the samples. It should be [NC], for instance.
Logged
FreePgs.com Forum
« Reply #33 on: December 01, 2005, 03:43:41 PM »

 Logged
markjay
Verified Account
Full Member
*

Karma: +3/-0
Offline Offline

Posts: 165


Blog entries (0)

View Profile WWW
« Reply #34 on: December 01, 2005, 07:22:07 PM »

i had tried your sample but your first sample blocks all images and the second can be still hotlinked...
you should test your sample thoroughly
Logged

webzone (archived)
Official Technical Support
Verified Account
Hero Member
*

Karma: +0/-0
Offline Offline

Posts: 508

Archived Account

Blog entries (0)

View Profile
« Reply #35 on: December 01, 2005, 07:47:00 PM »

i did all the necessary tests already. i admitted soon after i added my post that the first example might not work. however, the second one works well and really disables hotlinking.

Quote
you should test your sample thoroughly
or maybe should you use my samples better?
i mean : it works. i made all necessary tests and even more. i'm using it (temporarily) right now.

---
correction (5:55) : I also tested the code with more than one RewriteCond line and it works. My code can really restrict to directories and can allow multiple hosts (by using more than one RewriteCond in a row). Note however, that there is a little difference between the tested code and the published one (this error has been fixed since) where the dash (-) in RewriteRule was changed to a backslash.
« Last Edit: December 01, 2005, 09:12:15 PM by webzone » Logged
Pages: 1 2 [3]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!