Apacheの設定で mod_rewrite を利用しサブドメインを判定して DocumentRoot 以下のサブドメイン名のディレクトリに
アクセスする設定をします。
Apacheの設定ファイルに以下の内容を設定します。
LoadModule rewrite_module modules/mod_rewrite.so
OSがDebianの場合は上記の設定をせずに以下のコマンドを実行します。
# a2enmod rewrite
Apacheの設定ファイルのホスト設定箇所に以下の内容を追加します。
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.xxxxxx\.com+$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.xxxxxx\.com(.*) /$1$2 [L]
最後にApacheを再起動します。
# /etc/init.d/apache2 restart