Forum Moderators: phranque

Message Too Old, No Replies

IfModule sometimes causes 500 Error

         

EastTexas

7:29 pm on Mar 30, 2014 (gmt 0)

10+ Year Member



IfModule sometimes causes 500 Error...

Latest Victimizes I don't care about:

YisouSpider (Yisou Blocked)

Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.2) Firefox/3.5.2 (zh-CN & OLD Browser are Blocked)

Blank User Agent from ns2.justoweb.net (OVH is blocked)


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*(360spider|80legs|a6-indexer|aboundex|adnorm|ahrefs|archiver|atwatch|
babya|baidu|bandit|beetle|bullseye|casper|classbot|capture|catalog|cfnetwork|chinaclaw|clip|clshttp|client|collector|
commentreader|commerce|control|confusion|copier|copyscape|copub|copyrightcheck|cr4nk|craftbot|crawler|crazy|curl|cuwhois|
darwin|data|deepnet|devsoft|disco|domain|dotbot|download|easou|ecatch|e-dev|elefent|email|enhancer|exabot|
explorador|external|extract|eyenetie|fetch|flash|filter|flip|gabot|genieo|getright|go.?is|go!zilla|grab|grabber|grapeshot|
harvest|heritrix|httpclient|httrack|ichiro|indy|inventory|ipod|jakarta|java|kkman|ktxn|larbin|leacher|library|libww|
linkdex|linkpad|loader|mail.ru|meanpath|missigua|mj12bot|moget|mojeekbot|mot-mpx220|mutant|myie2).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(naver|netants|netscape|netseer|newt|niki|nikto|ninja|miner|nutch|offbyone|offline|
panscient|paros|pecl|phantomjs|piranha|pix|python|quester|reaper|regbot|sauger|scan|scraper|screener|sees|semalt|semrush|
seznam|sistrix|siteexplorer|sitesnagger|snippets|sogou|spbot|spider|sqworm|stripper|sucker|super|siphon|tarantula|teleport|turnitin|
urlappend|urllib|vampire|voila|webpictures|webspider|webster|wget|whack|win32|winhttp|wotbox|widow|win98|wisenut|wolf|wotbox|wwwoffle|
xaldon|y!oasis|yabrowser|yandex|yeti|yisou|youdao|yrspider|yx|zeerch|zemlya|zeus|zip|zyborg).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(comodo\ spider|microsoft\ url\ control|seo\ robot|windows\ 3|windows\ 3.1|windows\ 3.11|
windows\ 95|windows\ 98|win98|win\ 9x|windows\ 2000|win32).* [NC,OR]

RewriteCond %{HTTP_USER_AGENT} ^.*(ar-sa|cz|ee-es|fi-fi|ru|ua|zh-CN).* [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>

[edited by: phranque at 6:06 am (utc) on Mar 31, 2014]
[edit reason] fixed sidescroll [/edit]

lucy24

8:38 pm on Mar 30, 2014 (gmt 0)

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



I seriously doubt it's the <IfModule element itself that's causing the error. More likely you've got the module-- as everyone does-- which means the code is trying to execute, and then discovering an error.

I can have a closer look after someone has Dealt With the long lines. My browser window isn't that big :(

Now, about that
^.*

...

EastTexas

8:49 pm on Mar 30, 2014 (gmt 0)

10+ Year Member



Dito on the windows too small.
This is why the option in Old Opera 12.x fit to screen is a real winner!

Whats wrong w/ ^.* ?

EastTexas

3:13 am on Mar 31, 2014 (gmt 0)

10+ Year Member



I forgot to mention the code came from PerishablePress.com [perishablepress.com]

wilderness

9:21 am on Mar 31, 2014 (gmt 0)

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



forgot to mention the code came from


And why you keep posting (flawed) it here (puzzlement) multiple times after being advised of corrections, and seeing the effect of NOT including lines breaks in long syntax is a bigger mystery. Especially when it belongs in the SSID forum.

lucy24

9:43 am on Mar 31, 2014 (gmt 0)

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



Personally I wouldn't load down mod_rewrite with all that stuff. It can be done much more cleanly and simply using the mod_setenvif + mod_authxyzzy combination.

BrowserMatch something keep_out
BrowserMatch somethingelse keep_out
BrowserMatch thirdthing keep_out

Deny from env=keep_out

Dit[t]o on the windows too small.

If you can see that the lines are too long for the window, fer hevvins sakes why don't you do something about it at time of posting?

^.*

=

(i.e. null) and can therefore be omitted in its entirety.

Edit: What have you got against Finns, anyway? They've always seemed pretty innocuous to me. And rumor has it they've got the best educational system on the planet, which ought to count for something.

g1smd

5:14 pm on Apr 1, 2014 (gmt 0)

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



When the input sting is

foo-bar-quux-this-that-the-other-and-something-else

and your RegEx pattern is "
^.*this.*
", the effect is the pattern matching starts looking for "this" directly after the character shown in bold as specified by the leading ^.* element.

It then has to back off and retry multiple times to find "this" and then having eventually found it, the pattern matching then wastes more time reading all the way to the end as specified by the trailing .* element.

Remove the
^.*
and
.*
from the pattern. You want a "contains" match.

EastTexas

7:41 pm on Apr 2, 2014 (gmt 0)

10+ Year Member



Or a much simpler reason...

<Files 403.shtml>
order allow,deny
allow from all
</Files>

Changed to

<Files 403.shtml>
order allow,deny
</Files>


PS I have nothing against the Finns... If one tries to hack or use a Bad UA - ZAP 'em all. Don't feel bad I do the same thing to .cn, .ua, .ru, .su, .tr, .cz and more.

I'm not doing biz overseas, so I don't have a problem with it. They do the same thing to the USA & I don't blame them at all. We all want to keep our sites safe as possible.

Thanks again for all the help 8)

lucy24

10:33 pm on Apr 2, 2014 (gmt 0)

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



<Files 403.shtml>
order allow,deny
</Files>

An "order" declaration only kicks in when a request matches both elements or neither. So this form would result in all requests for the 403 page being denied. If you want the minimalist form, it would have to be
Order Deny,Allow


I tested this to make sure I'm not talking through my hat.