Forum Moderators: phranque

Message Too Old, No Replies

Zeus rewrite rules

Looking for rewrite help

         

ibroughton

6:02 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



Just found out that I can't use the standard RewriteRule to prevent image hotlinking on my site. How do I configure

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com/.*$ [NC]
RewriteRule \.(gif¦jpg)$ http://www.example.com/dontsteal.gif [R,L]

to run on Zeus?

[edited by: encyclo at 1:40 am (utc) on July 16, 2008]
[edit reason] examplified [/edit]

ibroughton

7:24 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



OK, I've found that the Zeus rewrite rules converter replaces

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?photos.example.com/.*$ [NC]
RewriteRule \.(gif¦jpg)$ - [F]

with

RULE_0_START:
match URL into $ with \.(gif¦jpg)$
if not matched then goto RULE_0_END
# Source line 2
# RewriteCond %{HTTP_REFERER}!^$
set SCRATCH:COND = %{IN:Referer}
match SCRATCH:COND into % with ^$
if matched then goto RULE_0_END
# Source line 3
# RewriteCond %{HTTP_REFERER}!^http://(www\.)?photos.example.com/.*$ [NC]
set SCRATCH:COND = %{IN:Referer}
insensitive match SCRATCH:COND into % with ^http://(www\.)?photos.example.com/.*$
if matched then goto RULE_0_END
# Source line 4
# Second half of: RewriteRule \.(gif¦jpg)$ - [F]
# This rule has [F]
set RESPONSE = 403
set BODY = Access to this page is denied
# Implicit [L] when converting
goto END
RULE_0_END:

or (and this is the one I'd prefer to use as it replaces the hotlinked image with a small gif) replaces

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?photos.example.com/.*$ [NC]
RewriteRule \.(gif¦jpg)$ [photos.example.com.gif...] [R,L]

with

RULE_0_START:
match URL into $ with \.(gif¦jpg)$
if not matched then goto RULE_0_END
# Source line 2
# RewriteCond %{HTTP_REFERER}!^$
set SCRATCH:COND =
match SCRATCH:COND into % with
if not matched then goto RULE_0_END
# Source line 3
# RewriteCond %{HTTP_REFERER}!^http://(www\.)?photos.example.com/.*$ [NC]
set SCRATCH:COND = %{IN:Referer}!^http://(www\.)?photos.example.com/.*$
match SCRATCH:COND into % with [NC]
if not matched then goto RULE_0_END
# Source line 4
# Second half of: RewriteRule \.(gif¦jpg)$ [photos.example.com...] [R,L]
set URL = [photos.example.com...]
# This rule has [R]
set RESPONSE = 302
set OUT:Location = %{URL}
set BODY = Please try <a href="%{URL}">here</a> instead\n
# Implicit [L] when converting
goto END
RULE_0_END:

but neither of these work. can anyone please help?

[edited by: encyclo at 1:43 am (utc) on July 16, 2008]
[edit reason] examplified [/edit]

Martin_Sach

9:43 am on Jun 8, 2005 (gmt 0)

10+ Year Member



I don't have the answer unfortunately but I am struggling with the same problem. The Zeus online documentation is not really aimed at webmasters using ISP facilities, it is aimed at ISP staff and people hosting their own servers.