apache 中 ServerAlias让多个域名绑定到同一空间

时间:2023-03-09 15:46:41
apache 中 ServerAlias让多个域名绑定到同一空间

在apache的虚拟主机中,如果书写了。ServerAlias www.a2.com www.a3.com这样的语句,就可以给虚拟主机增加多个域名,而且这些域名都访问同一个站点。

#Listen 81
<VirtualHost *:80>
    ServerName www.a1.com:80
    ServerAdmin webmaster@localhost
    DocumentRoot "F:/webserver/htdocs/a1"
    ServerAlias www.a2.com www.a3.com
    ErrorLog "logs/a1-error.log"
    CustomLog "logs/a1-access.log" common
    <Directory "F:/webserver/htdocs/a1">
    Options Indexes FollowSymLinks Includes
IndexOptions FancyIndexing ScanHTMLTitles
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
ScriptAlias /cgi-bin/ "F:/webserver/htdocs/a1/cgi-bin/"
<Directory "F:/webserver/htdocs/a1/cgi-bin/">
    AllowOverride None
    Options Indexes FollowSymLinks ExecCGI
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

上面的代码会让a1,a2,a3 三个域名都访问到同一个空间。