Welcome to WebmasterWorld Guest from 54.144.80.75

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess / RewriteCond problem

Multiple RewriteRule...

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

New User

10+ Year Member

joined:Sept 28, 2003
posts:3
votes: 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]

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

New User

10+ Year Member

joined:Sept 28, 2003
posts:3
votes: 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

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

Preferred Member

10+ Year Member

joined:May 14, 2003
posts:376
votes: 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]

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

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members