最近、mod_vhost_alias を使用して要求をドメインのようなディレクトリにルーティングする仮想ホスト構成を Apache に追加しました。ディレクトリが存在する場合、すべてが正常に機能します。私の考えでは、Apache にルーティングされたドメインを呼び出したが、対応する仮想ドキュメント ルートが存在しない場合、要求はデフォルトのホストによって処理されます。しかし、そうではありません。mod_rewrite を使わずにこれを行う解決策はありますか?
これは私の動的ホスト構成です:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerAlias *
UseCanonicalName Off
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/log/apache2/dhost_access.log vcommon
VirtualDocumentRoot /var/www/%0
VirtualScriptAlias /var/www/%0
</VirtualHost>
そして、これは私のデフォルトのホストです:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>