homepage Welcome to WebmasterWorld Guest from 54.242.231.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess / RewriteCond problem
Multiple RewriteRule...
FirstBorn




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

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




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

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




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

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




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

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

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

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved