added option to disable the defaults directory directive for document roots

This commit is contained in:
cheggo 2016-12-05 19:10:20 +01:00
parent 88d910923c
commit 4e50ed0fab
3 changed files with 10 additions and 2 deletions

View file

@ -46,6 +46,10 @@ You can add or override global Apache configuration settings in the role-provide
Add a set of properties per virtualhost, including `servername` (required), `documentroot` (required), `serveradmin` (optional), `serveralias` (optional) and `extra_parameters` (optional: you can add whatever additional configuration lines you'd like in here). Add a set of properties per virtualhost, including `servername` (required), `documentroot` (required), `serveradmin` (optional), `serveralias` (optional) and `extra_parameters` (optional: you can add whatever additional configuration lines you'd like in here).
apache_documentroot_directory_defaults: true
As the vhost file template automatically sets a default <Directory> directive for your document root, you can disable this by settings this value to `false` and add your own <Directory> directive for your document root via `extra_parameters`.
Here's an example using `extra_parameters` to add a RewriteRule to redirect all requests to the `www.` site: Here's an example using `extra_parameters` to add a RewriteRule to redirect all requests to the `www.` site:
- servername: "www.local.dev" - servername: "www.local.dev"

View file

@ -15,6 +15,10 @@ apache_remove_default_vhost: false
apache_global_vhost_settings: | apache_global_vhost_settings: |
DirectoryIndex index.php index.html DirectoryIndex index.php index.html
# Create default <Directory "{{apache_vhosts.documentroot}}">-Directive
# Set this to `false` for your own <Directory>-Directive in apache_vhosts.extra_parameters
apache_documentroot_directory_defaults: true
apache_vhosts: apache_vhosts:
# Additional properties: 'serveradmin, serveralias, extra_parameters'. # Additional properties: 'serveradmin, serveralias, extra_parameters'.
- servername: "local.dev" - servername: "local.dev"

View file

@ -14,7 +14,7 @@
{% if vhost.serveradmin is defined %} {% if vhost.serveradmin is defined %}
ServerAdmin {{ vhost.serveradmin }} ServerAdmin {{ vhost.serveradmin }}
{% endif %} {% endif %}
{% if vhost.documentroot is defined %} {% if vhost.documentroot is defined and apache_documentroot_directory_defaults %}
<Directory "{{ vhost.documentroot }}"> <Directory "{{ vhost.documentroot }}">
AllowOverride All AllowOverride All
Options -Indexes +FollowSymLinks Options -Indexes +FollowSymLinks
@ -61,7 +61,7 @@
{% if vhost.serveradmin is defined %} {% if vhost.serveradmin is defined %}
ServerAdmin {{ vhost.serveradmin }} ServerAdmin {{ vhost.serveradmin }}
{% endif %} {% endif %}
{% if vhost.documentroot is defined %} {% if vhost.documentroot is defined and apache_documentroot_directory_defaults %}
<Directory "{{ vhost.documentroot }}"> <Directory "{{ vhost.documentroot }}">
AllowOverride All AllowOverride All
Options -Indexes +FollowSymLinks Options -Indexes +FollowSymLinks