Serveralias: Server alias. It can be used in Apache to set the domain name received by the VM or to receive the domain name for wildcard resolution. The specific settings are as follows:
1. Set the VM to receive multiple domain names
A virtual host often receives multiple domain name resolutions. For example, a virtual host must simultaneously introduce two domain names, namely sanywork.cn and 51684.com, or two second-level domain names, such as www.sanywork.cn and www1.sanywork.cn. In this case, you can use serveralias to easily open the Apache setting file: httpd. conf.CodeMedium:
<Virtualhost 192.168.1.12>
Servername "sanywork.cn" # default domain name;
Serveralias 51684.com www1.sanywork.cn # different domain names are separated by spaces;
DocumentRoot "D: \ wwwroot \ sanywork.cn"
<Directory "D: \ wwwroot \ sanywork.cn">
Options indexes followsymlinks
AllowOverride all
</Directory>
</Virtualhost>
Save the httpd. conf file and restart Apche.
Ii. Receiving wildcard domain name resolution
A virtual host can receive wildcard domain name resolution and is also set through the severalias option. By setting this option, it can not only receive second-level wildcard domain name resolution, but also receive third-level and fourth-level wildcard domain name resolution, the specific settings are as follows:
<Virtualhost 192.168.1.12>
Servername "sanywork.cn" # default domain name;
Serveralias * .sanywork.cn # uses * to represent a wildcard domain name. To receive a third-level wildcard domain name resolution, you can write it as follows: * .my.sanywork.cn;
DocumentRoot "D: \ wwwroot \ sanywork.cn"
<Directory "D: \ wwwroot \ sanywork.cn">
Options indexes followsymlinks
AllowOverride all
</Directory>
</Virtualhost>
Save the httpd. conf file and restart Apche.
When you add a virtual host (virtualhost) record in Apache:
<Virtualhost *: 80>
Serveradmin admin @ localhost
DocumentRoot "E:/www/team"
Servername team.renrenstudy.com
# Serveralias company.renrenstudy.com
Errorlog "logs/vhosts/team_error.log"
Customlog "logs/vhosts/team_access.log" common
</Virtualhost>
ServernameThis is the domain name to be added. In this example, team.renrenstudy.com. If someone else accesses this domain name, Apache automatically resolves it to the E:/www/team directory, that is, the directory specified by DocumentRoot in this example.
In this case, I want someone else to access company.renrenstudy.com to parse this directory.Serveralias.AliasIsAliasThis is equivalent to giving team.renrenstudy.com the name of company.renrenstudy.com.