Changes

From SME Server
Jump to navigationJump to search
m
Line 120: Line 120:     
I haven't tested it, but I assume if you had no VirtualDomains defined and set the Primary Domain to be redirected you would still get the standard VirtualHost entry created and therefore still have access to server-manager etc. - [[User:Timn|Timn]] 12:54, 15 February 2010 (UTC)
 
I haven't tested it, but I assume if you had no VirtualDomains defined and set the Primary Domain to be redirected you would still get the standard VirtualHost entry created and therefore still have access to server-manager etc. - [[User:Timn|Timn]] 12:54, 15 February 2010 (UTC)
 +
 +
I have also created a file 30DomWebappRedirect in the same folder as above with following content
 +
{
 +
    # vim: ft=perl:
 +
 +
    use esmith::DomainsDB;
 +
    my $domains = esmith::DomainsDB->open_ro;
 +
 +
    $OUT = "";
 +
 +
    if (( $domains->get_prop($virtualHost, 'WebApp') || 'no') eq 'yes') {
 +
 +
        $haveSSL = (exists ${modSSL}{status} and ${modSSL}{status} eq "enabled") ?  'yes' : 'no';
 +
        my $webapp = $virtualHostContent;
 +
        my $webappStatus = ${$webapp}{'status'} || "disabled";
 +
        my $webappAccessType = ${$webapp}{'access'} || "SSL";
 +
        my $webappURL = <nowiki>''</nowiki>;
 +
        if (exists ${$webapp}{'URL'}) {
 +
            my $webappURL = ${$webapp}{'URL'};
 +
        }
 +
 +
        return "    # web application $webapp is disabled in this VirtualHost"
 +
                unless $webappStatus eq 'enabled';
 +
 +
        if (($port eq "80") && ($haveSSL eq 'yes') && ($webappAccessType eq 'SSL'))
 +
        {
 +
            $OUT .= "    RewriteRule ^/$webapp(/.*|\$)    https://%{HTTP_HOST}/\$1 [L,R]\n";
 +
            if (($webappURL || <nowiki>''</nowiki>) ne <nowiki>''</nowiki>) {
 +
                $OUT .= "    RewriteRule ^/$webappURL(/.*|\$)    https://%{HTTP_HOST}/\$1 [L,R]\n";
 +
            }
 +
            $OUT .= "    RewriteRule ^/(/.|\$)            https://%{HTTP_HOST}/\$1 [L,R]\n";
 +
        }
 +
        elsif ($port eq "80") {
 +
            $OUT .= "    RewriteRule ^/$webapp(/.*|\$)    http://%{HTTP_HOST}/\$1 [L,R]\n";
 +
            if (($webappURL || <nowiki>''</nowiki>) ne <nowiki>''</nowiki>) {
 +
                $OUT .= "    RewriteRule ^/$webappURL(/.*|\$)    http://%{HTTP_HOST}/\$1 [L,R]\n";
 +
            }
 +
        }
 +
        elsif ($port eq "443") {
 +
            $OUT .= "    RewriteRule ^/$webapp(/.*|\$)    https://%{HTTP_HOST}/\$1 [L,R]\n";
 +
            if (($webappURL || <nowiki>''</nowiki>) ne <nowiki>''</nowiki>) {
 +
                $OUT .= "    RewriteRule ^/$webappURL(/.*|\$)    https://%{HTTP_HOST}/\$1 [L,R]\n";
 +
            }
 +
        }
 +
    }
 +
}
 +
Now any reference to the original web application alias will be redirected to root. It also catches any alternative URL set.
 +
 +
Also you can enforce SSL by
 +
config setprop webapp access SSL
 +
or not
 +
config setprop webapp access public
 +
 +
Again, works for me with joomla. [[User:Timn|Timn]] 15:02, 17 February 2010 (UTC)

Navigation menu