diff --git a/roles/httpd/domainrewrite/tasks/main.yml b/roles/httpd/domainrewrite/tasks/main.yml new file mode 100644 index 0000000000..35087460c1 --- /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 0000000000..cdd5d061c2 --- /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 0000000000..0191513219 --- /dev/null +++ b/roles/httpd/domainrewrite/vars/main.yml @@ -0,0 +1,2 @@ +path: ^/$ +status: 302