Commit 6493b93d authored by anarcat's avatar anarcat Committed by anarcat

#535098 - enable domain redirection in the backend

parent e91a05e4
......@@ -357,15 +357,17 @@ function _provision_drupal_maintain_aliases($url) {
// First we delete all the old aliases
_provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'));
$aliases = drush_get_option('aliases');
if (!is_array($aliases)) {
$aliases = explode(",", $aliases);
}
foreach($aliases as $alias) {
if (trim($alias)) {
provision_path("symlink", $url, drush_get_option('docroot_path') . "/sites/" . $alias,
dt("Created symlink for alias @alias", array("@alias" => $alias)),
dt("Could not create symlink for alias @alias", array("@alias" => $alias)));
if (!drush_get_option('redirection')) {
$aliases = drush_get_option('aliases');
if (!is_array($aliases)) {
$aliases = explode(",", $aliases);
}
foreach($aliases as $alias) {
if (trim($alias)) {
provision_path("symlink", $url, drush_get_option('docroot_path') . "/sites/" . $alias,
dt("Created symlink for alias @alias", array("@alias" => $alias)),
dt("Could not create symlink for alias @alias", array("@alias" => $alias)));
}
}
}
}
......
......@@ -49,6 +49,7 @@ function drush_provision_drupal_post_provision_verify($url = NULL) {
if (PROVISION_CONTEXT_SITE) {
_provision_drupal_rebuild_caches($url);
drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('redirection', drush_get_option('redirection'), 'site');
drush_set_option('installed', TRUE, 'site');
}
}
......
......@@ -5,7 +5,7 @@
*/
function drush_provision_apache_provision_disable($url = NULL) {
drush_set_option('redirect_url', drush_get_option('web_disable_url'));
_provision_apache_create_vhost_config($url, _provision_apache_redirect_template());
_provision_apache_create_vhost_config($url, _provision_apache_disabled_template());
_provision_apache_restart_apache();
}
......@@ -58,12 +58,19 @@ function _provision_apache_default_template() {
}
/**
* The default template for disabled sites
* The template for site redirection
*/
function _provision_apache_redirect_template() {
return file_get_contents(dirname(__FILE__) ."/provision_apache_vhost_redirect.tpl.php");
}
/**
* The default template for disabled sites
*/
function _provision_apache_disabled_template() {
return file_get_contents(dirname(__FILE__) ."/provision_apache_vhost_disabled.tpl.php");
}
/**
* The template for platform configuration settings
*/
......@@ -90,6 +97,9 @@ function _provision_apache_create_vhost_config($url, $template = NULL) {
if (is_null($template)) {
$template = _provision_apache_default_template();
}
if ($options['redirection']) {
$template .= _provision_apache_redirect_template();
}
if (!is_array($options['aliases'])) {
$options['aliases'] = explode(",", $options['aliases']);
}
......
......@@ -6,7 +6,7 @@
ServerName <?php print $site_url; ?>
<?php if (is_array($aliases)) :
<?php if (!$redirection && is_array($aliases)) :
foreach ($aliases as $alias_url) :
if (trim($alias_url)) : ?>
ServerAlias <?php print $alias_url; ?>
......
<VirtualHost *:80>
<?php if ($site_mail) : ?>
ServerAdmin <?php print $site_mail; ?>
<?php endif;?>
DocumentRoot <?php print $publish_path; ?>
ServerName <?php print $site_url; ?>
RewriteEngine on
# the ? at the end is to remove any query string in the original url
RewriteRule ^(.*)$ <?php print $redirect_url . '/' . $site_url ?>?
<?php if (is_array($aliases)) :
foreach ($aliases as $alias) : ?>
ServerAlias <?php print $alias; ?>
<?php
endforeach;
endif; ?>
</VirtualHost>
......@@ -2,13 +2,8 @@
<?php if ($site_mail) : ?>
ServerAdmin <?php print $site_mail; ?>
<?php endif;?>
DocumentRoot <?php print $publish_path; ?>
ServerName <?php print $site_url; ?>
RewriteEngine on
# the ? at the end is to remove any query string in the original url
RewriteRule ^(.*)$ <?php print $redirect_url . '/' . $site_url ?>?
ServerName <?php print array_pop($aliases); ?>
<?php if (is_array($aliases)) :
foreach ($aliases as $alias) : ?>
......@@ -17,4 +12,5 @@
endforeach;
endif; ?>
RedirectMatch permanent ^(.*) http://<?php print $site_url ?>$1
</VirtualHost>
......@@ -5,7 +5,7 @@
*/
function drush_provision_apache_pre_provision_restore($url) {
drush_set_option('redirect_url', drush_get_option('web_maintenance_url'));
_provision_apache_create_vhost_config($url, _provision_apache_redirect_template());
_provision_apache_create_vhost_config($url, _provision_apache_disabled_template());
_provision_apache_restart_apache();
}
......
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