声明同一虚拟主机的多个端口:
SSLStrictSNIVHostCheck off
# Apache setup which will listen for and accept SSL connections on port 443.
Listen 443
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:443
<VirtualHost *:443>
ServerName domain.localhost
DocumentRoot "/Users/<my_user_name>/Sites/domain/public"
<Directory "/Users/<my_user_name>/Sites/domain/public">
Order allow,deny
Allow from all
</Directory>
# SSL Configuration
SSLEngine on
...
</VirtualHost>
如何为“ domain.localhost”声明一个新端口(“ listen”,ServerName等)?
如果我添加以下代码,则apache也可以对“ domain.localhost”的所有其他子域(subdomain1.domain.localhost,subdomain2.domain.localhost等)起作用(太多):
<VirtualHost *:80>
ServerName pjtmain.localhost:80
DocumentRoot "/Users/Toto85/Sites/pjtmain/public"
RackEnv development
<Directory "/Users/Toto85/Sites/pjtmain/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3
只是要注意。您不能将https和非https虚拟主机合并为一个。<VirtualHost *:80 *:443>。80不能启用“ SSLEngine”。对于SSL和非SSL,必须具有2个单独的VirtualHost声明。
—
加塞克2014年
—
肯·英格拉姆