ワイルドカード DNS エントリがあるため、*.mydomain.tld がサーバーに送信されます。私は nginx を使用しています。次の 2 つの conf ファイルがあります。
- デフォルト
- myconf.conf
私のconfファイルは次のようになります:
デフォルト:
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
root /var/www/website;
index index.html index.htm;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
}
myconf.conf:
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
root /home/me/www/website;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
# orig # server_name localhost;
server_name me.mydomain.tld;
access_log /home/me/logs/me.mydomain.tld.access.log;
error_log /home/me/logs/me.mydomain.tld.error.log warn;
location / {
try_files $uri $uri/ $uri.php?$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
次のようにドメインをブラウズすると、読み込まれる conf ファイルが表示されます。
- me.mydomain.tld は、myconf.conf で定義されたルート ディレクトリをロードします。
- mydomain.tld は、デフォルトで定義されたルート ディレクトリを読み込みます
- any.mydomain.tld は、myconf.conf で定義されたルート ディレクトリをロードします。
デフォルトが本来あるべきキャッチオールではないことの何が問題になっていますか? any.mydomain.tld は、デフォルトの conf ファイルにルート ディレクトリをロードする必要があります。