Welcome to WebmasterWorld Guest from 54.221.28.179

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess / RewriteCond problem

Multiple RewriteRule...

     

FirstBorn

7:14 pm on Sep 28, 2003 (gmt 0)

10+ Year Member



Hi FirstBorn! Yell at me, I deleted your post. ;) Then check your Stickymail at the top of your screen: "Welcome FirstBorn: You have mail: [ inbox:1 - unread:0 ]"

Tap, tap, tap, I'm drumming my fingers impatiently waiting for your edited post! :)

[edited by: DaveAtIFG at 8:02 pm (utc) on Sep. 28, 2003]

FirstBorn

9:29 pm on Sep 28, 2003 (gmt 0)

10+ Year Member



Thanks for the Sticky Mail and sorry again. :) Okay, here is the edited post:

Hi everyone,

I have written this little .htaccess to stop people from direct linking to my site:


Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com(/)?.*$ [NC]
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ [mydomain.com...] [R,NC]

This code works perfectly, but this picture isn't appriciated by some people. So I wanted to add 1 domain with an extra RewriteCond/RewriteRule so that they don't get to see the picture, but a 403 Error. So I made this piece of code:


Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com(/)?.*$ [NC]
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ [mydomain.com...] [R,NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?someothersite.com(/)?.*$ [NC]
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ [F,NC]

But it doesn't work. Could someone please tell me what I'm doing wrong? Thanks a lot!

FirstBorn

wkitty42

9:55 pm on Sep 28, 2003 (gmt 0)

10+ Year Member



i'll give it a stab...

for one thing, you need to exclude that domain in the same way that you exclude your domain... so at least, you need to copy that rule into the previous set...


Options +FollowSymlinks
RewriteEngine on

# grab blank referrers
RewriteCond %{HTTP_REFERER}!^$
# don't block my domain
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com(/)?.*$ [NC]
# don't block someother domain
RewriteCond %{HTTP_REFERER}!^http://(www\.)?someothersite.com(/)?.*$ [NC]
# send them something they don't want
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ http://mydomain.com/some_insulting_image.jpe [R,NC]

# check for someother domain
RewriteCond %{HTTP_REFERER} ^http://(www\.)?someothersite.com(/)?.*$ [NC]
# send them a failure on the pic
RewriteRule .*\.(gif夸pg夸peg在mp如ng)$ [F,NC]

[edit] oops - fix error [/edit]

jdMorgan

12:29 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



On the last rule, you'll need to add a "null" URL using the "-" character.

RewriteRule \.(gif夸pg夸peg在mp如ng)$ - [F,NC]

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month