Skip to content
Snippets Groups Projects
Commit 2bafa88b authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

Merge pull request #572 from tsteiner2/issue-491

Closes #491.
parents 9541ccec 9a9802a3
No related branches found
No related tags found
No related merge requests found
.htaccess
.htaccess-subsite-map.txt
sites/sites.php
sites/*/
!sites/all/
......
# This file is automatically generated.
# Do not edit it unless you know what you are doing!
# %UNL_CREATION_TOOL_STUB%
......@@ -56,15 +56,22 @@ DirectoryIndex index.php index.html index.htm
<IfModule mod_rewrite.c>
RewriteEngine on
# THIS SECTION IS AUTOMATICALY GENERATED.
# THIS SECTION IS FOR UNL SUBSITES
# DO NOT EDIT!!!!
# Add the following line to your httpd.conf
# RewriteMap drupal_subsites txt:<DRUPAL_ROOT>/.htaccess-subsite-map.txt
# Do not uncomment the previous line.
RewriteRule .*/cron.php cron.php
RewriteRule .*/update.php update.php
RewriteRule ^(.*?/(misc|modules|sites|themes))(.*) ${drupal_subsites:$1|$1}$3
RewriteCond ${drupal_subsites://%{HTTP_HOST}%{REQUEST_URI}|NOT_FOUND} !^NOT_FOUND$
RewriteRule (.*) ${drupal_subsites://%{HTTP_HOST}%{REQUEST_URI}|$1} [R,L]
# %UNL_CREATION_TOOL_STUB%
# END SUBSITE AREA.
# END AUTOMATICALLY GENERATED AREA.
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or
......
......@@ -393,24 +393,24 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) {
$site_path .= '/';
}
unl_require_writable(DRUPAL_ROOT . '/.htaccess');
unl_require_writable(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$stub_token = '# %UNL_CREATION_TOOL_STUB%';
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess');
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$stub_pos = strpos($htaccess, $stub_token);
if ($stub_pos === FALSE) {
throw new Exception('Unable to find stub site entry in .htaccess.');
throw new Exception('Unable to find stub site entry in .htaccess-subsite-map.txt.');
}
$new_htaccess = substr($htaccess, 0, $stub_pos)
. "# %UNL_START_{$site_or_alias}_ID_{$site_id}%\n";
foreach (array('misc', 'modules', 'sites', 'themes') as $drupal_dir) {
$new_htaccess .= " RewriteRule $site_path$drupal_dir/(.*) $drupal_dir/$1\n";
$new_htaccess .= "$site_path$drupal_dir $drupal_dir\n";
}
$new_htaccess .= "# %UNL_END_{$site_or_alias}_ID_{$site_id}%\n\n"
. $stub_token
. substr($htaccess, $stub_pos + strlen($stub_token));
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess', $new_htaccess);
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess-subsite-map.txt', $new_htaccess);
}
function unl_remove_site_from_htaccess($site_id, $is_alias) {
......@@ -421,9 +421,9 @@ function unl_remove_site_from_htaccess($site_id, $is_alias) {
$site_or_alias = 'SITE';
}
unl_require_writable(DRUPAL_ROOT . '/.htaccess');
unl_require_writable(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess');
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$site_start_token = "\n# %UNL_START_{$site_or_alias}_ID_{$site_id}%";
$site_end_token = "# %UNL_END_{$site_or_alias}_ID_{$site_id}%\n";
......@@ -437,34 +437,32 @@ function unl_remove_site_from_htaccess($site_id, $is_alias) {
$new_htaccess = substr($htaccess, 0, $start_pos)
. substr($htaccess, $end_pos + strlen($site_end_token))
;
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess', $new_htaccess);
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess-subsite-map.txt', $new_htaccess);
}
function unl_add_page_alias_to_htaccess($site_id, $host, $path, $to_uri) {
unl_require_writable(DRUPAL_ROOT . '/.htaccess');
unl_require_writable(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$stub_token = '# %UNL_CREATION_TOOL_STUB%';
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess');
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$stub_pos = strpos($htaccess, $stub_token);
if ($stub_pos === FALSE) {
throw new Exception('Unable to find stub page alias entry in .htaccess.');
throw new Exception('Unable to find stub page alias entry in .htaccess-subsite-map.txt.');
}
$new_htaccess = substr($htaccess, 0, $stub_pos)
. "# %UNL_START_PAGE_ALIAS_ID_{$site_id}%\n"
. " RewriteCond %{HTTP_HOST} ^{$host}$\n"
. " RewriteCond %{REQUEST_URI} ^{$path}$\n"
. " RewriteRule (.*) {$to_uri} [R,L]\n"
. "//$host$path $to_uri\n"
. "# %UNL_END_PAGE_ALIAS_ID_{$site_id}%\n\n"
. $stub_token
. substr($htaccess, $stub_pos + strlen($stub_token));
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess', $new_htaccess);
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess-subsite-map.txt', $new_htaccess);
}
function unl_remove_page_alias_from_htaccess($site_id) {
unl_require_writable(DRUPAL_ROOT . '/.htaccess');
unl_require_writable(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess');
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess-subsite-map.txt');
$site_start_token = "\n# %UNL_START_PAGE_ALIAS_ID_{$site_id}%";
$site_end_token = "# %UNL_END_PAGE_ALIAS_ID_{$site_id}%\n";
......@@ -478,7 +476,7 @@ function unl_remove_page_alias_from_htaccess($site_id) {
$new_htaccess = substr($htaccess, 0, $start_pos)
. substr($htaccess, $end_pos + strlen($site_end_token))
;
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess', $new_htaccess);
_unl_file_put_contents_atomic(DRUPAL_ROOT . '/.htaccess-subsite-map.txt', $new_htaccess);
}
function unl_add_alias_to_sites_php($alias_site_dir, $real_site_dir, $alias_id) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment