Created
January 5, 2017 07:35
-
-
Save bcremer/38437c5b6609a4f5431f838319ae327e to your computer and use it in GitHub Desktop.
htaccess_to_vhost
This file contains hidden or 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
#!/usr/bin/env bash | |
# | |
# Converts .htaccess files to vhost directory directives | |
# | |
# http://httpd.apache.org/docs/2.4/howto/htaccess.html#when | |
# You should avoid using .htaccess files completely if you have | |
# access to httpd main server config file. Using .htaccess files | |
# slows down your Apache http server. Any directive that you can | |
# include in a .htaccess file is better set in a Directory block, | |
# as it will have the same effect with better performance. | |
# | |
# The use of .htaccess files can be disabled completely by setting | |
# the AllowOverride directive to none | |
# AllowOverride None | |
set -o nounset | |
set -o errexit | |
set -o pipefail | |
find -type f -name ".htaccess" -print0 | while read -d $'\0' file | |
do | |
dir=$(dirname $(readlink -f "$file")) | |
echo "<Directory $dir>" | |
cat $file | sed "s/^/ /g" | |
echo "" # make sure we have a newline after the last statement | |
echo "</Directory>" | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment