It's possible to add headers with other methods, but using .htaccess files is certainly a good method.
You can have one .htaccess file per directory, which is logical, since two files with the same name aren't allowed. They contain instructions/settings for Apache, just like httpd.conf, but on a per-directory base.
For every HTTP request, Apache will look for every .htaccess file that applies to that request. This is the .htaccess file in the current directory, the one in the parent directory, parent of the parent, etc.
You can do a lot of useful things with .htaccess files, but I'll just tell you how to add headers. If you want to add certain headers to all files in a directory and all subdirectories, just add the following in your .htaccess:
Code:
#Additional headers
Header set Cache-Control "private, max-age=5184000"
Header set Last-Modified "Wed, 12 Aug 2009 00:00:00 GMT"
Where you -obviously- change the header name and contents.
It's also possible to do this on a per-file basis:
Code:
#(This is a comment.)
#I'm not sure how you can specify multiple files, but it's probably something like this:
#<Files "a.php" "b.php" "c.php">
<Files something.php>
Header set Cache-Control "private, max-age=5184000"
Header set Last-Modified "Wed, 12 Aug 2009 00:00:00 GMT"
</Files>
It's also possible to specify a directory, simply change <Files> into <Directory>.
The most useful variant however uses regex to find out which files it applies to, saving you the time from specifying all files manually.
Code:
<FilesMatch "\.(html|htm|php)$">
Header set Cache-Control "private, max-age=5184000"
Header set Last-Modified "Wed, 12 Aug 2009 00:00:00 GMT"
</FilesMatch>