Jump to content

Include File In .htaccess?

Recommended Posts

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




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?

Link to post
Share on other sites

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.

Link to post
Share on other sites

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 :) )

Link to post
Share on other sites



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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...