Forum Moderators: phranque

Message Too Old, No Replies

Can I use htaccess to block all the visitor using Linux

         

Jason200784

11:59 am on May 22, 2008 (gmt 0)

10+ Year Member



I want to block all the proxy server from accessing my website. Many proxy server are using Linux, so if I can block all the vistor using linux, maybe I can make it.

I have written some codes, but they don't work

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} .*html$¦.*php$¦.*png$ [NC]
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{HTTP_USER_AGENT} Linux
RewriteCond %{HTTP_USER_AGENT} Unix [NC,OR]
RewriteRule ^.+ - [F]

So what't wrong with these codes? thanks

wilderness

2:13 pm on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteEngine on (if not turned on previously)
RewriteCond %{HTTP_USER_AGENT} (Linux¦Unix) [NC,OR]
RewriteRule .* - [F]

The forum alters the pipe character and requires correction before use.

jdMorgan

3:53 pm on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You must remove the [OR] flag on the final RewriteCond -- The code won't work with it there. Also, to preserve the filetype condition, you can move it to the RewriteRule:

RewriteCond %{HTTP_USER_AGENT} Linux¦Unix [NC]
RewriteRule \.(html¦php¦png)$ - [F]

It wasn't clear why you had the requirement for a blank referrer in your code. If that is what you wanted, put that line back in.

As Wilderness stated, you must replace the broken pipe "¦" characters with solid pipe characters before use; Posting on this forum modifies the pipe characters.

Jim

wilderness

4:05 pm on May 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You must remove the [OR] flag on the final RewriteCond

An error my reward for copying and pasting from multiple lines ;)