Forum Moderators: phranque

Message Too Old, No Replies

File size limit to .htaccess file

Definitive answer?

         

Amadon

2:02 am on Dec 31, 2007 (gmt 0)

10+ Year Member



Another poster to this forum says that he likes to limit the file size of his .htaccess file to 25Kb but prefers to keep them below 20Kb.

Mine is already 22Kb due to many 301 redirects. I want to block access of certain countries (because their inhabitants are constantly using stolen credit card numbers on my site) and that would put my .htaccess file way over the limit.

Does anybody have a way out of this jam?

jdMorgan

2:05 am on Dec 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I know, there is no limit... except for the maximum filesize determined by the operating system and the performance degradation you are willing to put up with.

I've peaked out at well over 100kB before (during a scraper storm) with no ill effects except a slight slow-down serving pages/resources.

Jim

Pfui

11:31 am on Jan 3, 2008 (gmt 0)

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



My top level .htaccess is currently ~ 650k with no apparent speed degradation on Apache 1.3.x, RewriteLogLevel 2.

The file's a whopper because it's chock-full of commented-out lines/notes to myself, like this snippet courtesy of a 2005 Jim Morgan post:) --

## BLOCK *Faked* blank referer -OR- UA (malicious agents supply a literal hyphen as UA string)
## either the referrer or the user-agent to be a literal "-", which is a rare but nasty exploit
## [webmasterworld.com...]
RewriteCond [from that post; etc.]

-- so actual commands probably weigh in at ~200k, give or take.

Entries are in sections so the server doesn't have to process the entire file for every single hit. (Higher-level RewriteLogs are eye-poppers!)

For example, I have a BANNED UAs section with loads of [NC,OR] conditions ending in a single [F,L] rule. Other sections include BANNED IPs, BANNED HOSTs; there are even monthly sections where I keep an eye on new, iffy visitors (...if I have time to get really, really obsessive:)

The sectional scheme is also a plus because if I goof up one section's code, I don't lose ALL protections.

FWIW