I'm adding a line of Perl code to a Makefile that searches for something like the following block in an httpd.conf and replaces "None" with "All" for the AllowOverride.
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
The code I'm trying to run from the command line is as follows:
sudo perl -p -i -e 's/(<Directory "\/var\/www\/html">.*AllowOverride )(None)/\1 All/' httpd.conf
But I cannot get it to work. I'm using the two capture groups for keeping the first group the same and replacing the second one.
Any help is greatly appreciated.
EDIT: this resolved it
sudo perl -0777 -p -i -e 's/(<Directory \"\/var\/www\/html\">.*?AllowOverride) (None)/\1 All/s' httpd.conf