VirtualHostのServerNameとServerAlias

心のそこから反省しています。
というのも、本当に今の今までServerAliasというディレクティブを知らなかったからです。この無知ぶりが何をもたらすかと言うと…

<VirtualHost *>
  ServerName www.example.jp
  DocumentRoot /path/to/example.jp/htdocs
  <Directory /path/to/example.jp/htdocs>
    Options +ExecCGI +FollowSymLinks
  </Directory>
</VirtualHost>

<VirtualHost *>
  ServerName example.jp
  DocumentRoot /path/to/example.jp/htdocs
  <Directory /path/to/example.jp/htdocs>
    Options +ExecCGI +FollowSymLinks
  </Directory>
</VirtualHost>

などという事を、そりゃーもういくつもいくつも同じ事書いてしまうわけですよ!!

恥ずかしいったらない。本当に赤面しました。あのサーバやあのサーバやあのサーバ、無駄に長い設定を書いてしまったサーバは何台あるやら。そしてその面倒を引き継いでしまった皆様、あぁあぁあああごめんなさいごめんなさい。

↑で2つ同じ事を書いたVirtualHostの設定は

<VirtualHost *>
  ServerName www.example.jp
  ServerAlias example.jp
  DocumentRoot /path/to/example.jp/htdocs
  <Directory /path/to/example.jp/htdocs>
    Options +ExecCGI +FollowSymLinks
  </Directory>
</VirtualHost>

たったのこんだけになるんです。心のそこから反省。何かと改めたいと思います。はぁ。