NTT系のレンタルサーバーWebArenaのSuiteXを用があって使っていた時の話なのですが、このレンタルサーバーはマルチドメインが対応しています。私はマルチドメインと聞いてVirtualHost的な物を想像していたのですが、ここのマルチドメインはなんとhtacccess(Rewrite)で実現していました。
http://web.arena.ne.jp/suitex/support/manual/hp/multidomain.html
▲ホームページ~マルチドメイン設定ツール
1 2 3 4 5 6 7 |
# Enable RewriteEngine. RewriteEngine On # Main RewriteRule for multidomain. RewriteCond %{HTTP_HOST} ^(example.org|www.example.org) RewriteCond %{REQUEST_URI} !^/(example.org|www.example.org)/ RewriteRule ^(.*)$ /%{HTTP_HOST}/$1/ [L] |
▲設定例
私的にこういうのはVirtualHostで実現かなぁーと思っていたのですが、こんな方法でも実現できるんですね。VirtualHostに比べると再起動が不要という大きな利点がありそうです。