Dienstag, 25. November 2008

Apache2: Redirect Subdomains to directory

Rewrite Mod anschalten und apache neu starten
a2enmod rewrite && invoke-rc.d apache2 restart


/etc/apache2/sites-enabled/000-default

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.de([.*]?)$
RewriteCond /var/www/%1 -d
RewriteRule ^(.*) http://domain\.de/%1$1 [L]

Das heißt also:
asd.domain.de/qwe -> domain.de/asd/qwe
asd.domain.de -> domain.de/asd
www.domain.de -> domain.de

Keine Kommentare: