Closed Thread Icon

Preserved Topic: .htaccess to Replace Image (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12219" title="Pages that link to Preserved Topic: .htaccess to Replace Image (Page 1 of 1)" rel="nofollow" >Preserved Topic: .htaccess to Replace Image <span class="small">(Page 1 of 1)</span>\

 
Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-15-2002 04:24

So, I'm trying to incorporate the following into my .htaccess to prevent others from linking to my images from their sites:

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?bigwaste.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?ozoneasylum.com/.*$ [NC]
RewriteRule \.(gif

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 05-15-2002 05:06

I honestly wouldn't have a clue what the correct syntax would be but shouldn't the apology.gif at least mention your domain?

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-15-2002 08:31

If your .htaccess file is located in the root folder (where apology.gif resides), server will go into infinitie loop when trying to redirect to apology.gif (which will also be blocked), and that's why people get red X after some period of time (after timeout). Try to move .htaccess to some other folder (i.e. where your images are located), and see what will happen.

BTW This topic belongs in Server-Side Scripting Board...


Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-15-2002 19:57

Hmm... Moving it works, but now the problem is that it only applies to that directory down.

Oh, I bet if I change that one file to an uppercase extension (everything else in the site is lowercase) then it would allow that one image.

...yep, worked!

Thanks!

(BTW, I thought this topic might be appropriate for SSS, but figured it would also help a lot of people who don't normally frequent the scripting topics.)

Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-19-2002 03:25

Whoa! I just noticed something. I'm here at work and every image is being blocked and replaced with the "sorry" image. Would the fact that I'm having to go through a proxy server cause this?

The weird thing is that it's only happening on machines with IE 6 installed, not on any of the machines with IE 5.

And - get this - only if there's no trailing slash after the domain! In other words:

http://www.texastwisted.com goes screwy
http://www.texastwisted.com/ is fine

(BTW, do not consider the code in the post above to be what's actually in Texas Twisted's .htaccess. I use the same syntax, but the appropriate domain.)





[This message has been edited by Wes (edited 05-19-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-19-2002 11:22

As you have noticed the problem is with trailing slash. For some reason web browser isn't automatically redirected to the address with trailing slash (this can be caused by proxy server, and also by screwed IE installation). To make it work with and without trailing slash, just modify regular expression in mod_rewrite condition so that it doesn't include slash at the end, like this:

RewriteCond %{HTTP_REFERER} !^http://(www\.)?texastwisted.com.*$ [NC]


Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-19-2002 18:35

I was hoping it would that simple. I just didn't want to start removing anything since I don't completely understand the syntax.

I'll test it from work tonight to make sure all is well.


Wes
Paranoid (IV) Mad Scientist

From: Inside THE BOX
Insane since: May 2000

posted posted 05-19-2002 23:45

I'm here at work and all seems well once again!

Thanks, Max.


Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 05-20-2002 03:37

Would something like this work:

RewriteCond %{HTTP_REFERER} !^http://(*\.)?domain.com.*$ [NC]

So, say www.domain.com, blah.domain.com, and moreblah.domain.com would work? I'm just curious as I tend to have something like:
www.domain.com for the production site
dev.domain.com for testing/development
webmail.domain.com for web based email portal



mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-20-2002 07:26

You forgot to add "." any character operator. Also, I would use "+" quantifier instead of "*" quantifier. The correct code should look something like this:

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?domain.com.*$ [NC]

Optionally, you can specify all allowed sub-domains, like this:

RewriteCond %{HTTP_REFERER} !^http://((www

« BackwardsOnwards »

Show Forum Drop Down Menu