From 8831af7f89bf4746fbbad8aa4aa700f6567d9dae Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Thu, 11 Feb 2016 19:44:14 +0100
Subject: [PATCH] - workaround for apache < 2.4

---
 install/tpl/apache_ispconfig.conf.master | 6 +++---
 server/conf/vhost.conf.master            | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/install/tpl/apache_ispconfig.conf.master b/install/tpl/apache_ispconfig.conf.master
index 937c2f5cff..634567c0c2 100644
--- a/install/tpl/apache_ispconfig.conf.master
+++ b/install/tpl/apache_ispconfig.conf.master
@@ -122,13 +122,13 @@ Alias /.well-known/acme-challenge /usr/local/ispconfig/interface/acme/.well-know
 <Directory /usr/local/ispconfig/interface/acme/.well-known/acme-challenge>
 		<tmpl_if name='apache_version' op='>' value='2.2' format='version'>
 		Require all granted
+		RewriteEngine on
+		RewriteCond %{REQUEST_FILENAME} ^/\.well-known/acme-challenge
+		RewriteRule ^ - [END]
 		<tmpl_else>
         Order allow,deny
         Allow from all
 		</tmpl_if>
-		RewriteEngine on
-		RewriteCond %{REQUEST_FILENAME} ^/\.well-known/acme-challenge
-		RewriteRule ^.*$ - [END]
 </Directory>
 
 NameVirtualHost *:80
diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master
index 3e7ec811da..dbee3a3375 100644
--- a/server/conf/vhost.conf.master
+++ b/server/conf/vhost.conf.master
@@ -397,14 +397,17 @@
 		RewriteEngine on
 <tmpl_if name='seo_redirect_enabled'>
 		RewriteCond %{HTTP_HOST} <tmpl_var name='seo_redirect_operator'>^<tmpl_var name='seo_redirect_origin_domain'>$ [NC]
+		<tmpl_if name='apache_version' op='<' value='2.4' format='version'>RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/</tmpl_if>
 		RewriteRule ^(.*)$ http<tmpl_if name='ssl_enabled'>s</tmpl_if>://<tmpl_var name='seo_redirect_target_domain'>$1 [R=301,NE,L]
 </tmpl_if>
 <tmpl_loop name="alias_seo_redirects">
 		RewriteCond %{HTTP_HOST} <tmpl_var name='alias_seo_redirect_operator'>^<tmpl_var name='alias_seo_redirect_origin_domain'>$ [NC]
+		<tmpl_if name='apache_version' op='<' value='2.4' format='version'>RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/</tmpl_if>
 		RewriteRule ^(.*)$ http<tmpl_if name='ssl_enabled'>s</tmpl_if>://<tmpl_var name='alias_seo_redirect_target_domain'>$1 [R=301,NE,L]
 </tmpl_loop>
 <tmpl_loop name="redirects">
 		RewriteCond %{HTTP_HOST}   <tmpl_var name='rewrite_domain'>$ [NC]
+		<tmpl_if name='apache_version' op='<' value='2.4' format='version'>RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/</tmpl_if>
 <tmpl_if name="rewrite_is_url" op="==" value="n">
 		RewriteCond %{REQUEST_URI} !^/webdav/
 		RewriteCond %{REQUEST_URI} !^/php5-fcgi/
@@ -418,6 +421,7 @@
 <tmpl_else>
 <tmpl_if name='rewrite_to_https' op='==' value='y'>
         RewriteCond %{HTTPS} off
+        <tmpl_if name='apache_version' op='<' value='2.4' format='version'>RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/</tmpl_if>
         RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 </tmpl_if>
 </tmpl_if>
-- 
GitLab