TheCanadian Posted October 20, 2006 Posted October 20, 2006 Hi All! I'm wondering if anyone knows how to include a file to be processed within the .htaccess file. What I'm looking to do is have a list of IPs generated by a CGI be included for processing in my .htaccess file. Basically, I have a section like this: <Files *.cgi> order allow,deny allow from all deny from XX.XX.XX.XX deny from XX.XX.XX.XX ...etc... </Files> Then I have a CGI I wrote which catches spam bots trying to post to a form on my site, and logs their IP address to a text file in the "deny from XX.XX.XX.XX" fashion. I'd like to have my .htaccess refer to this file to add them to my "deny from" list for CGIs. Can this be done? Quote
MikeJ Posted October 20, 2006 Posted October 20, 2006 Unfortunately, you cannot include files in .htaccess. Quote
TheCanadian Posted October 20, 2006 Author Posted October 20, 2006 Darn! Well, I don't like the idea of automatically editing the .htaccess directly through CGI, so I guess I'll just have to periodically cut & paste the list myself. Thanks for the info! Quote
NFreak Posted October 23, 2006 Posted October 23, 2006 Since we're on the topic of including files, is there a way to have a header.php and a footer.php file get processed on every page? Currently, I just put the include lines in my code at the beginning and end manually, but there are some pages on my site that I made before I knew about including, and it would be nice to be able to update them. Quote
TCH-Andy Posted October 23, 2006 Posted October 23, 2006 As far as I'm aware, the only way is via an inclusion in the php. (Unless you wanted to redirect every page to a single php file, that adds the header / footer, and then includes the information from the page they asked for .... but that get's very messy ) Quote
surefire Posted October 23, 2006 Posted October 23, 2006 TCH-Andy, Messy to code? Can you elaborate? It's actually the very process I use on many sites, and was wondering why you think it's messy. Quote
TCH-Andy Posted October 23, 2006 Posted October 23, 2006 Surefire, Purely because he has some files which already have include pages, and some that don't, and the pages aren't already designed to be used as includes, so you would need to take account of that in the coding of the main page (or rewrite many of the other pages). If you are starting your design from scratch, using that method (I have on a couple of my sites) then I'd agree, it's not messy then. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.