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.
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(

View File

@ -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

View File

@ -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}
</VirtualHost>
@ -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}
</VirtualHost>
<!-- END: main -->