Commit a48cda86 authored by anarcat's avatar anarcat Committed by Antoine Beaupre
Browse files

avoid duplication of virtual hosts

before this patch, redirection virtual hosts were created with a duplicate ServerName, which seems to be working, but is needlessly confusing

after this patch, the redirection vhosts are created only based on the aliases provided and not the site_url

this implies that to do generic redirections (e.g. for SSL) you may need to push your site_url in the aliases array. that has been done in SSL so that all hosts (ie. aliases and the site_url) are redirected to the site_url, which is not appropriate for regular vhosts (because it would mean a infinite redirection loop)
parent c7cb8ec9
......@@ -26,6 +26,8 @@ function provision_ssl_provision_apache_vhost_config($url, $options) {
// XXX: we need a better way to identify if this is legit
provision_path('exists', drush_get_option('vhost_path') . '/' . $url . '_80', FALSE, NULL, dt("Overwriting existing vhost %url:80 with redirection", array('%url' => $url)));
$newoptions = $options;
// in the redirection template, the ServerName is the first alias in the list
array_push($newoptions['aliases'], $options['site_url']);
$newoptions['site_port'] = 80;
_provision_apache_create_config($url . '_80', $newoptions, _provision_apache_redirect_template());
......@@ -3,14 +3,17 @@
ServerAdmin <?php print $site_mail; ?>
<?php endif;?>
ServerName <?php print $site_url; ?>
<?php if (is_array($aliases) && count($aliases)): ?>
ServerName <?php print array_pop($aliases); ?>
<?php if (is_array($aliases)) :
foreach ($aliases as $alias) : ?>
ServerAlias <?php print $alias; ?>
endif; ?>
<?php if (count($aliases)): ?>
ServerAlias <?php print join(" ", $aliases); ?>
<?php endif; ?>
<?php else:
# this should never happen and has the potential of creating an infinite redirection loop
ServerName <?php print $site_url ?>
<?php endif; ?>
<?php if ($ssl_redirect): ?>
RedirectMatch permanent ^(.*) https://<?php print $site_url ?>$1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment