Forum Moderators: coopster & phranque

Message Too Old, No Replies

.htaccess

My syntax doesn't work

         

Edge

12:09 am on Mar 1, 2002 (gmt 0)

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



I'm having trouble getting my Rewrite to work with user agent that contain a space such as Teleport Pro . How do I properly syntax this user agent so that my server (apache) recognizes it? If I use a space between the "t" and "P" I get a internal 500 error.

The following is my .htaccess file.

Thanks in advance.

<Files .htaccess>
deny from all
</Files>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^EmailCollector [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^webbandit [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^Webster [OR]
RewriteCond %{HTTP_USER_AGENT} ^MSProxy/2.0 [OR]
RewriteCond %{HTTP_USER_AGENT} ^MSFrontPage [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web*Downloader*[OR]
RewriteCond %{HTTP_USER_AGENT} ^WebEMailExtrac [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport*Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^combine [OR]
RewriteCond %{HTTP_USER_AGENT} ^UtilMind [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bloodhound [OR]
RewriteCond %{HTTP_USER_AGENT} ^e-collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^htmlgobble [OR]
RewriteCond %{HTTP_USER_AGENT} ^JavaBee [OR]
RewriteCond %{HTTP_USER_AGENT} ^Robofox [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetcher [OR]
RewriteCond %{HTTP_USER_AGENT} ^tarspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^webmirror [OR]
RewriteCond %{HTTP_USER_AGENT} ^webvac [OR]
RewriteCond %{HTTP_USER_AGENT} ^w3mir [OR]
RewriteCond %{HTTP_USER_AGENT} ^JoBo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Java [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline [OR]
RewriteCond %{HTTP_USER_AGENT} ^Larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Crescent [OR]
RewriteCond %{HTTP_USER_AGENT} ^Email [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/2.0 [OR]
RewriteCond %{HTTP_USER_AGENT} ^Down2Web [OR]
RewriteCond %{HTTP_USER_AGENT} ^Microsoft*
RewriteRule ^.* - [F]
RewriteCond %{HTTP_REFERER} ^http://www.iaea.org$
RewriteRule !^http://[^/.]\.myplace.com.* - [F]

bird

2:29 am on Mar 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteCond %{HTTP_USER_AGENT} ^Teleport*Pro [OR]

You seem to be confusing this with shell wildcards. In the grep type regular expressions applied here, the "*" is used to repeat the preceding character zero or more times. Your pattern would therefor match all of "TeleporPro", "TeleportPro", "TeleporttttPro", etc. What you want is either this:

RewriteCond %{HTTP_USER_AGENT} ^Teleport.Pro [OR]

where the "." matches any arbitrary character, or:

RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]

where the "\ " matches a literal space character (the backslash escapes the space from the normal "end of pattern" meaning).

There's actually another funny thing in your file:

RewriteRule !^http://[^/.]\.myplace.com.* - [F]

The pattern in the RewriteRule is compared only to the path component of the URL, without the hostname. This means that the rule will always match (a negative match against something that will never happen), with is actually what you want, but you could do it much simpler:

RewriteRule ^.*$ - [F]

In fact, you could simply add your iaea referrer condition to the list above with an [OR] flag and do away with the extra rule.

Edge

4:54 pm on Mar 1, 2002 (gmt 0)

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



Thanks Bird,

I'm on the update.

Edge

10:02 pm on Mar 8, 2002 (gmt 0)

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



Hey, I removed the

"RewriteCond %{HTTP_REFERER} ^http://www.iaea.org$
RewriteRule !^http://[^/.]\.myplace.com.* - [F] "

as you suggested and just got pounded by him.

Must be something different about my server.

bird

10:45 pm on Mar 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Uh, I didn't recommend to remove it completely, but to include this condition with those for the other rule...

Edge

6:11 pm on Mar 9, 2002 (gmt 0)

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



Oops, I didn't write my post correctly in the heat of the moment.
You Wrote:

"In fact, you could simply add your iaea referrer condition to the list above with an [OR] flag and do away with the extra rule."

I did move the iaea referrer condition as you suggested and this failed on my hosts server.

This is what I did:
....
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/2.0 [OR]
RewriteCond %{HTTP_USER_AGENT} ^Down2Web [OR]
RewriteCond %{HTTP_REFERER} ^http://www.iaea.org$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^Microsoft*
RewriteRule ^.* - [F]

Sorry for the confusion

bird

6:57 pm on Mar 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What exactly do you mean by "failed"?
You will always find them in your log files. Just that they will be listed there with an 403 response and zero transfer size instead as with a 200 as before. There's no way to keep them from "pounding" your server, you can just prevent them from actually getting served any useful data.