updated plain-site redirect to preserve the request host(name)

This commit is contained in:
AnsibleGuy 2022-01-13 18:38:47 +01:00
parent f028bfec59
commit 089dc4fbfb
2 changed files with 7 additions and 1 deletions

View File

@ -108,6 +108,7 @@ default_site_config:
ip:
http_versions: [2, 1]
plain_site: true # if http site (only used for redirect to https) should be created
plain_redirect: 'preserve_domain' # keep hostname from plain request => any other value will set the redirect to the main-domain
config: {} # site-specific setting-value pairs
config_additions: [] # lines that will 1-to-1 be appended to the site-config

View File

@ -30,7 +30,12 @@
Protocols {% if 2 in site.http_versions %}h2c {% endif %}{% if 1 in site.http_versions or 2 not in site.http_versions %}http/1.1{% endif %}
# redirect all to secure connection
Redirect permanent / https://{{ site.domain }}
RewriteEngine On
{% if site.plain_redirect == 'preserve_domain' %}
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
{% else %}
RewriteRule ^ https://{{ site.domain }}%{REQUEST_URI}
{% endif %}
</VirtualHost>
{% endif %}