Forum Moderators: phranque

Message Too Old, No Replies

How (if at all) can I call an include file frrom .htaccess?

         

the_nerd

10:24 am on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I'd like to have a list of "denied" IP-ranges in a file that's created on the fly whenever someone behaves like a bot.

This file should be included into my .htaccess file. Of course I could insert the list into .htaccess but I'm afraid something could happen (program crashes with .htaccess half-cooked, website down, you name it)

Are there any include-drectives for .htaccess?

Thanks for any hint,

the-nerd

jdMorgan

3:08 pm on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no "include" functionality in .htaccess. However, you could write a PERL script to re-generate your .htaccess file periodically, including a new block list either from a local source (using file reads on the same server), or from a remote server using an HTTP_capable library such as libwww-PERL. By setting this script up as a cron job (a time-scheduled task), you could run it daily to update the block list.

In fact, if you use bad-bot scripts that generate new local blocklist entries, you could use another script on your designated 'central blocklist server' to accept new blocklist entries from all servers sharing the blocklist; All servers would 'donate' their new blocklist entries to this script, the script would merge the blocklists, and then each server could fetch the merged blocklist, so they'd all be using the same list - the list to which all contributed.

If I only had the time... and a good deal more PERL expertise... :)

Jim

the_nerd

4:24 pm on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks, Jim,

you could run it daily to update the block list.

... but I need to block these @@**%&%$ NOW (whenever they decide to hit my poor server from their dynamic IP). I'll try to fix it with PHP, because I'm waaaay to old for new "foreign" languages ;-)

nerd.

jdMorgan

5:56 pm on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you seen (or implemented) Key_Master's bad-bot script [webmasterworld.com], or xlcus' and AlexK's badly-behaved bot script [webmasterworld.com]? -- Those may be more like what you are looking for. In both cases, the script "edits" your .htaccess file on-the-fly. So this is not an 'include' of code into .htaccess, but rather the reverse: adding code to .htaccess.

Jim

the_nerd

6:05 pm on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you seen (or implemented) Key_Master's bad-bot script, or xlcus' and AlexK's badly-behaved bot script?

not yet, but I'm off the change that ....

Thanks for the tip!