Forum Moderators: coopster & phranque

Message Too Old, No Replies

Help! trap.pl -- htaccess rewrite?

         

catmoran

2:03 am on Mar 30, 2003 (gmt 0)

10+ Year Member



Dangerous newbie here.

Using my incredible powers of cut & paste, I implemented Key_Master's trap.pl [webmasterworld.com] this evening. I had an existing .htaccess which I replaced with his, but I'd like to re-integrate the functionality of my old .htaccess back in. This is the old content:


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

Can someone help?

jdMorgan

2:07 am on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Catmoran,

Just put your original two lines back in there, minus the opening "RewriteEngine on".
Or am I missing the point of the problem?

Jim
<added>To clarify: You only need one "RewriteEngine on" statement at the top, not one for each set of RewriteConds and RewriteRules.</added>

andreasfriedrich

2:22 am on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to make the RewriteRule [httpd.apache.org] match case insensitively.

RewriteRule [httpd.apache.org] \.(gif¦jpe?g)$ - [F,NC]

And you do not need the .* since it does not add any constraints on your match and is not needed for backreferences.

Andreas

catmoran

2:23 am on Mar 30, 2003 (gmt 0)

10+ Year Member



Or am I missing the point of the problem?

You might be. (Or I just might be confused.) To clarify, Key_Master said:

Replace (or create) your .htaccess file with the following text. For the sake of simplicity and usability, this .htaccess file doesn't use the deny from 0.0.0.0 type of entries. All banning should be done using the SetEnvIf directive. Make sure they appear at the top of the .htaccess file and before the following text.


<Files ~ "^.*$">
order allow,deny
allow from all
deny from env=ban
</Files>

I assumed that meant that I would need to replace my old directives with something in a similar <files> format?

andreasfriedrich

2:27 am on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don´t.

jdMorgan

2:30 am on Mar 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, just add your old stuff back in after the </files> line.

Jim

catmoran

2:42 am on Mar 30, 2003 (gmt 0)

10+ Year Member



Thank you!