Some fixes and improvements related to the generation of Apache rewrite

rules (Feature: htdocsfallback).
This commit is contained in:
Michael Hierweck 2012-10-21 11:34:33 +02:00
parent 8985614812
commit 4e0098e2c2
3 changed files with 34 additions and 10 deletions

View File

@ -325,21 +325,21 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
// TODO: This code should be cleaned up after switching to the velocity template engine. // TODO: This code should be cleaned up after switching to the velocity template engine.
query.setParameter("option", "htdocsfallback"); query.setParameter("option", "htdocsfallback");
if (query.getResultList().isEmpty()) { if (query.getResultList().isEmpty()) {
templateVars.put("HTDOCSFALLBACKHTTP", templateVars.put("NOHTDOCSFALLBACKHTTP",
" RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" + " RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" +
" RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" + " RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" +
" RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:80)?$ [novary]\n" + " RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:80)?$ [novary]\n" +
" RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d\n" + " RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d\n" +
" RewriteRule ^(.*) - [redirect=404,last]"); " RewriteRule ^(.*) - [redirect=404,last]\n");
templateVars.put("HTDOCSFALLBACKHTTPS", templateVars.put("NOHTDOCSFALLBACKHTTPS",
" RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" + " RewriteCond %{REQUEST_URI} !^/cgi-bin/\n" +
" RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" + " RewriteCond %{REQUEST_URI} !^/fastcgi-bin/\n" +
" RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:443)?$ [novary]\n" + " RewriteCond %{HTTP_HOST} ^(.+)\\.{DOM_HOSTNAME}\\.?(:443)?$ [novary]\n" +
" RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} !-d\n" + " RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} !-d\n" +
" RewriteRule ^(.*) - [redirect=404,last]"); " RewriteRule ^(.*) - [redirect=404,last]\n");
} else { } else {
templateVars.put("HTDOCSFALLBACKHTTP", "\n"); templateVars.put("NOHTDOCSFALLBACKHTTP", "\n");
templateVars.put("HTDOCSFALLBACKHTTPS", "\n"); templateVars.put("NOHTDOCSFALLBACKHTTPS", "\n");
} }
Processor domSetupProcessor = new CompoundProcessor( Processor domSetupProcessor = new CompoundProcessor(

View File

@ -36,8 +36,14 @@
RewriteEngine On RewriteEngine On
RewriteOptions Inherit 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 AddType application/x-httpd-php .php .php5 .php4 .php3
Action application/x-httpd-php /fastcgi-bin/phpstub Action application/x-httpd-php /fastcgi-bin/phpstub
@ -85,7 +91,13 @@
RewriteEngine On RewriteEngine On
RewriteOptions Inherit 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 AddType application/x-httpd-php .php .php5 .php4 .php3
Action application/x-httpd-php /fastcgi-bin/phpstub Action application/x-httpd-php /fastcgi-bin/phpstub

View File

@ -32,7 +32,13 @@
RewriteEngine On RewriteEngine On
RewriteOptions Inherit 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}
</VirtualHost> </VirtualHost>
@ -71,8 +77,14 @@
RewriteEngine On RewriteEngine On
RewriteOptions Inherit 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}
</VirtualHost> </VirtualHost>
<!-- END: main --> <!-- END: main -->