-
-
Save Rud5G/2878564 to your computer and use it in GitHub Desktop.
.htaccess combiner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Colin Mollenhour | |
# | |
# Usage: Run from the webroot, .htaccess-combined will be created. | |
dest='.htaccess-combined' | |
pwd=`pwd` | |
echo -n "" > $dest | |
while read -r file; do | |
loc=`dirname $file` | |
if [[ "$loc" =~ '^\./downloader/pearlib/\w+' ]]; then continue; fi | |
if [[ "$loc" = "." ]]; then | |
dir=$pwd | |
else | |
dir="$pwd/${loc#*/}" | |
fi | |
echo "<Directory $dir >" >> $dest | |
cat $file | sed 's/^/ /' | awk 1 >> $dest | |
echo -e "</Directory>\n" >> $dest | |
done < <(find -L . -name \.htaccess -type f | awk '{ print length, $0 }' | sort -n | awk '{$1=""; print $0}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment