From 4e0098e2c287f904abdc7b28d6e89b160e231a5b Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Sun, 21 Oct 2012 11:34:33 +0200 Subject: [PATCH] Some fixes and improvements related to the generation of Apache rewrite rules (Feature: htdocsfallback). --- .../hsadmin/mods/dom/DomainProcessorFactory.java | 12 ++++++------ .../de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl | 16 ++++++++++++++-- .../de/hsadmin/mods/dom/httpd-vhost-static.jtpl | 16 ++++++++++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index 3a320a3..2cb54a1 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -325,21 +325,21 @@ public class DomainProcessorFactory implements EntityProcessorFactory { // TODO: This code should be cleaned up after switching to the velocity template engine. query.setParameter("option", "htdocsfallback"); if (query.getResultList().isEmpty()) { - templateVars.put("HTDOCSFALLBACKHTTP", + templateVars.put("NOHTDOCSFALLBACKHTTP", " RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" + " RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" + " RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:80)?$ [novary]\n" + " RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d\n" + - " RewriteRule ^(.*) - [redirect=404,last]"); - templateVars.put("HTDOCSFALLBACKHTTPS", + " RewriteRule ^(.*) - [redirect=404,last]\n"); + templateVars.put("NOHTDOCSFALLBACKHTTPS", " RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" + " RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" + " RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:443)?$ [novary]\n" + " RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} !-d\n" + - " RewriteRule ^(.*) - [redirect=404,last]"); + " RewriteRule ^(.*) - [redirect=404,last]\n"); } else { - templateVars.put("HTDOCSFALLBACKHTTP", "\n"); - templateVars.put("HTDOCSFALLBACKHTTPS", "\n"); + templateVars.put("NOHTDOCSFALLBACKHTTP", "\n"); + templateVars.put("NOHTDOCSFALLBACKHTTPS", "\n"); } Processor domSetupProcessor = new CompoundProcessor( diff --git a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl index eede2f5..b419eb2 100644 --- a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl +++ b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl @@ -36,8 +36,14 @@ RewriteEngine On RewriteOptions Inherit + + RewriteCond %{REQUEST_URI} !^/cgi-bin/ + RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ + RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:[0-9]+)?$ [novary] + RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d + RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last] - {HTDOCSFALLBACKHTTP} +{NOHTDOCSFALLBACKHTTP} AddType application/x-httpd-php .php .php5 .php4 .php3 Action application/x-httpd-php /fastcgi-bin/phpstub @@ -85,7 +91,13 @@ RewriteEngine On RewriteOptions Inherit - {HTDOCSFALLBACKHTTPS} + RewriteCond %{REQUEST_URI} !^/cgi-bin/ + RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ + RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:[0-9]+)?$ [novary] + RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} -d + RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1}$1 [last] + +{NOHTDOCSFALLBACKHTTPS} AddType application/x-httpd-php .php .php5 .php4 .php3 Action application/x-httpd-php /fastcgi-bin/phpstub diff --git a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl index b740da3..aa43cdb 100644 --- a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl +++ b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl @@ -32,7 +32,13 @@ RewriteEngine On RewriteOptions Inherit - {HTDOCSFALLBACKHTTP} + RewriteCond %{REQUEST_URI} !^/cgi-bin/ + RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ + RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:[0-9]+)?$ [novary] + RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d + RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last] + +{NOHTDOCSFALLBACKHTTP} @@ -71,8 +77,14 @@ RewriteEngine On RewriteOptions Inherit + + RewriteCond %{REQUEST_URI} !^/cgi-bin/ + RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ + RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:[0-9]+)?$ [novary] + RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} -d + RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1}$1 [last] - {HTDOCSFALLBACKHTTPS} +{NOHTDOCSFALLBACKHTTPS} \ No newline at end of file