summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/httpd/domainrewrite/tasks/main.yml22
-rw-r--r--roles/httpd/domainrewrite/templates/domainrewrite.conf6
-rw-r--r--roles/httpd/domainrewrite/vars/main.yml2
3 files changed, 30 insertions, 0 deletions
diff --git a/roles/httpd/domainrewrite/tasks/main.yml b/roles/httpd/domainrewrite/tasks/main.yml
new file mode 100644
index 000000000..35087460c
--- /dev/null
+++ b/roles/httpd/domainrewrite/tasks/main.yml
@@ -0,0 +1,22 @@
+# Expected vars
+# - website...
+# - destname..
+# - path..
+# - target..
+# - status..
+
+- name: Copy in domain rewrite for {{destname}} ({{website}}{{path}})
+ template: >
+ src={{item}}
+ dest=/etc/httpd/conf.d/{{website}}/{{destname}}-rewrite.conf
+ owner=root
+ group=root
+ mode=0644
+ with_first_found:
+ - "{{roles}}/httpd/domainrewrite/templates/domainrewrite.{{destname}}.conf"
+ - "{{roles}}/httpd/domainrewrite/templates/domainrewrite.conf"
+ notify:
+ - restart httpd
+ tags:
+ - httpd
+ - httpd/domainrewrite
diff --git a/roles/httpd/domainrewrite/templates/domainrewrite.conf b/roles/httpd/domainrewrite/templates/domainrewrite.conf
new file mode 100644
index 000000000..cdd5d061c
--- /dev/null
+++ b/roles/httpd/domainrewrite/templates/domainrewrite.conf
@@ -0,0 +1,6 @@
+RewriteEngine On
+{% if path == '/favicon.ico$' %}
+RewriteRule {{path}} {{target}} [P]
+{% else %}
+RewriteRule {{path}} {{target}} [R={{status}},L]
+{% endif %}
diff --git a/roles/httpd/domainrewrite/vars/main.yml b/roles/httpd/domainrewrite/vars/main.yml
new file mode 100644
index 000000000..019151321
--- /dev/null
+++ b/roles/httpd/domainrewrite/vars/main.yml
@@ -0,0 +1,2 @@
+path: ^/$
+status: 302