vhost.tpl.php 3.36 KB
Newer Older
1
<VirtualHost *:<?php print $http_port; ?>>
Adrian Rossouw's avatar
Adrian Rossouw committed
2
<?php if ($this->site_mail) : ?>
3
  ServerAdmin <?php  print $this->site_mail; ?>
4
<?php endif;?>
5

6 7 8 9 10 11 12
<?php
$aegir_root = drush_get_option('aegir_root');
if (!$aegir_root && $server->aegir_root) {
  $aegir_root = $server->aegir_root;
}
?>

13 14
  DocumentRoot <?php print $this->root; ?>

Adrian Rossouw's avatar
Adrian Rossouw committed
15
  ServerName <?php print $this->uri; ?>
16 17 18 19 20 21 22 23 24 25 26

  SetEnv db_type  <?php print urlencode($db_type); ?>

  SetEnv db_name  <?php print urlencode($db_name); ?>

  SetEnv db_user  <?php print urlencode($db_user); ?>

  SetEnv db_passwd  <?php print urlencode($db_passwd); ?>

  SetEnv db_host  <?php print urlencode($db_host); ?>

27 28
  SetEnv db_port  <?php print urlencode($db_port); ?>

29

30
<?php
31
if (sizeof($this->aliases)) {
32 33 34
  foreach ($this->aliases as $alias) {
    print "  ServerAlias " . $alias . "\n";
  }
35
}
36 37 38 39 40
?>

<IfModule mod_rewrite.c>
  RewriteEngine on
<?php
41
if ($this->redirection || $ssl_redirection) {
42

43
  if ($ssl_redirection && !$this->redirection) {
44
    print " # Redirect aliases in non-ssl to the same alias on ssl.\n";
45 46
    print " # Except for /.well-known/acme-challenge/ to prevent potential problems with Let's Encrypt\n";
    print " RewriteCond %{REQUEST_URI} '!/.well-known/acme-challenge/'\n";
47
    print " RewriteRule ^/*(.*)$ https://%{HTTP_HOST}/$1 [NE,L,R=301]\n";
48
  }
49
  elseif ($ssl_redirection && $this->redirection) {
50
    print " # Redirect all aliases + main uri to the selected alias https uri.\n";
51 52
    print " # Except for /.well-known/acme-challenge/ to prevent potential problems with Let's Encrypt\n";
    print " RewriteCond %{REQUEST_URI} '!/.well-known/acme-challenge/'\n";
53
    print " RewriteRule ^/*(.*)$ https://{$this->redirection}/$1 [NE,L,R=301]\n";
54
  }
55
  elseif (!$ssl_redirection && $this->redirection) {
56
    print " # Redirect all aliases to the selected alias.\n";
57 58
    print " RewriteCond %{HTTP_HOST} !^{$this->redirection}$ [NC]\n";
    print " RewriteRule ^/*(.*)$ http://{$this->redirection}/$1 [NE,L,R=301]\n";
59 60 61
  }
}
?>
62 63 64 65
  RewriteRule ^/files/(.*)$ /sites/<?php print $this->uri; ?>/files/$1 [L]
  RewriteCond <?php print $this->site_path; ?>/files/robots.txt -f
  RewriteRule ^/robots.txt /sites/<?php print $this->uri; ?>/files/robots.txt [L]
</IfModule>
66 67 68 69

<?php print $extra_config; ?>

    # Error handler for Drupal > 4.6.7
70
    <Directory ~ "sites/.*/files">
71 72 73 74 75 76 77 78 79 80
      <Files *>
        SetHandler This_is_a_Drupal_security_line_do_not_remove
      </Files>
      Options None
      Options +FollowSymLinks

      # If we know how to do it safely, disable the PHP engine entirely.
      <IfModule mod_php5.c>
        php_flag engine off
      </IfModule>
81 82
    </Directory>

83 84 85
    # Prevent direct reading of files in the private dir.
    # This is for Drupal7 compatibility, which would normally drop
    # a .htaccess in those directories, but we explicitly ignore those
helmo's avatar
helmo committed
86
    <Directory ~ "sites/.*/private">
87 88 89 90 91 92 93 94 95 96 97
      <Files *>
        SetHandler This_is_a_Drupal_security_line_do_not_remove
      </Files>
      Deny from all
      Options None
      Options +FollowSymLinks

      # If we know how to do it safely, disable the PHP engine entirely.
      <IfModule mod_php5.c>
        php_flag engine off
      </IfModule>
98
    </Directory>
99

100 101
<?php
$if_subsite = $this->data['http_subdird_path'] . '/' . $this->uri;
102
if (provision_hosting_feature_enabled('subdirs') && provision_file()->exists($if_subsite)->status()) {
103 104 105
  print "  Include " . $if_subsite . "/*.conf\n";
}
?>
106

107
</VirtualHost>