Aggregating Or Combining All htaccess Files
In order to obtain greater performance while using the Apache HTTP server you may want to consider disabling .htaccess reads and aggregating all of these files, then placing the results in httpd.conf or an included configuration file.
This will increase performance as Apache will not have to read and interpret .htaccess files for every request. The following shell script can be placed in a filename of your choice, we will use 'htagg' for the example. Also /var/www/vhosts may also be changed to / if you would like to combine ALL .htaccess files, not just virtual hosts.
The Aggregation Shell Script
#!/bin/bash
for file in `find /var/www/vhosts -type f -name '.htaccess'`; do
echo -e "\n<Directory `dirname $file`>"
cat $file
echo -e "\n</Directory>"
done > aggregated-htaccess.confExecuting The Script
Executing the script is very simple. A file named aggregated-htaccess.conf will be created in the directory where 'htagg' is executed.
# ./htaggViewing The Results
To view results ensuring that they have worked properly execute the command below.
# cat aggregated-htaccess.conf | moreDisabling Overrides Or Htaccess Files
This is quite simple and can be done by placing or modifying the directive below in httpd.conf
AllowOverride None
Delicious
Digg
StumbleUpon
Reddit
Facebook