diff --git a/templates/haproxy_cfg.jinja2 b/templates/haproxy_cfg.jinja2
index 12c16e713bddf8373f2cfa89805eff48d6f77df0..bdfb0fca3aa07e66a7a29af7c9a953d1e3f805b6 100644
--- a/templates/haproxy_cfg.jinja2
+++ b/templates/haproxy_cfg.jinja2
@@ -84,11 +84,11 @@ frontend http_in
 {% for path in redirect.paths|default([]) %}
 {% if not path.deny|default(false) %}
 {% if path.regex is not defined or path.from is not defined %}
-  redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path','path_beg')}} /{{path.from}}{% endif %} }
+  redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}}{% endif %} }
 {% endif %}
 {% endif %}
 {% endfor %}
-{% if (from != redirect.to or redirect.protocol|default('https') == 'https') and from != "." %}
+{% if (from != redirect.to or redirect.protocol|default('https') == 'https') and redirect.paths is not defined %}
   redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{ from }} }
 {% endif %}
 {% endfor %}
@@ -194,11 +194,11 @@ frontend https_in_{{ cert.ip }}
 {% for path in redirect.paths|default([]) %}
 {% if not path.deny|default(false) %}
 {% if path.regex is not defined or path.from is not defined %}
-  redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path','path_beg')}} /{{path.from}}{% endif %} }
+  redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}}{% endif %} }
 {% endif %}
 {% endif %}
 {% endfor %}
-{% if (from != redirect.to or redirect.protocol|default('https') != 'https') and from != "." %}
+{% if (from != redirect.to or redirect.protocol|default('https') != 'https') and redirect.paths is not defined %}
   redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{ from }} }
 {% endif %}
 {% endfor %}