Virtuellen Host einrichten (Ubuntu): Unterschied zwischen den Versionen
Erscheinungsbild
Keine Bearbeitungszusammenfassung |
|||
| Zeile 61: | Zeile 61: | ||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
<VirtualHost *:80> | <VirtualHost *:80> | ||
ServerName | ServerName SOURCE.ch | ||
RedirectMatch ^/(.*)$ https:// | ServerAlias *.SOURCE.ch | ||
RedirectMatch ^/(.*)$ https://www.TARGET.ch/$1 | |||
</VirtualHost> | </VirtualHost> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Version vom 15. November 2017, 09:59 Uhr
Virtuellen Host erstellen
zum Verzeichnis gehen.
cd /etc/apache2/sites-available
Eine Datei erstellen
sudo nano example.conf
#Drupal installation
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/example
ServerName example.dan
<Directory "/var/www/example">
AllowOverride All
Require all granted
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_drupal.log
CustomLog ${APACHE_LOG_DIR}/access_drupal.log combined
</VirtualHost>
alternativ: vorhandene .conf-Datei kopieren und anpassen
sudo sh -c 'cat VORLAGE.conf | sed 's/SUCHEN/ERSETZEN/g' > NEUEDOMAIN.conf'
Seite Aktivieren mit folgendem Befehl.
sudo a2ensite example.conf
Apache neu starten
sudo service apache2 reload
Virtuellen Host Löschen
sudo a2dismod example.conf
Virtuellen Host Alternative
#Drupal installation
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/example
ServerName example.ch
ServerAlias *.example.ch
<Directory "/var/www/html/example">
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>
Weiterleitung
<VirtualHost *:80>
ServerName SOURCE.ch
ServerAlias *.SOURCE.ch
RedirectMatch ^/(.*)$ https://www.TARGET.ch/$1
</VirtualHost>