VirtualDocumentRoot

VirtualDocumentRootでまとめてこう書ける。

ServerName xxxx.xxx
ServerAlias *.xxxx.xxx
VirtualDocumentRoot "/home/apache/%0/htdocs"

【apache】VirtualDocumentRootで、ディレクトリを作るだけでサブドメインが作れる at softelメモ

変数

VirtualDocumentRootの%0の部分は
test.example.comに置き換えられているのですが
それぞれの変数の対応は以下のようになっています。

test.example.comの場合

%0 test.example.com
%1 test
%2 example
%3 com
%1.1 t
%1.2 e
%1.3 s
%1.4 t
%1.1+ test
%1.2+ est
%1.3+ st
%1.4+ t

https://www.seeds-std.co.jp/seedsblog/699.html

0 the whole name
1 the first part
2 the second part
-1 the last part
-2 the penultimate part
2+ the second and all subsequent parts
-2+ the penultimate and all preceding parts
1+ and -1+ the same as 0

mod_vhost_alias - Apache HTTP Server Version 2.4

test.example.comの場合

%1.-1 t
%1.-2 s
%1.-2+ tes