我希望我的网站支持非 SSL 和 SSL 访问。我需要做的是复制非 SSL 配置并将端口更改为 443,然后添加 SSL 内容。管理起来不太理想!
有没有办法合并这两个配置?
这是我当前的配置:
<VirtualHost *:80>
ServerName www.site.tld
ServerAlias site.tld
suPHP_UserGroup site site
DocumentRoot /path/to/site/www
<Directory /path/to/site/www>
AllowOverride All
Order allow,deny
allow from all
Options -MultiViews
</Directory>
ExpiresActive On
ExpiresByType image/gif "access plus 7 days"
ExpiresByType image/jpeg "access plus 7 days"
ExpiresByType image/png "access plus 7 days"
ExpiresByType image/x-icon "access plus 7 days"
ExpiresByType image/ico "access plus 7 days"
ExpiresByType text/css "access plus 2 days"
</VirtualHost>
<VirtualHost *:443>
ServerName www.site.tld
ServerAlias site.tld
suPHP_UserGroup site site
DocumentRoot /path/to/site/www
<Directory /path/to/site/www>
AllowOverride All
Order allow,deny
allow from all
Options -MultiViews
</Directory>
SSLEngine On
SSLCertificateFile /etc/ssl/private/site.crt
ExpiresActive On
ExpiresByType image/gif "access plus 7 days"
ExpiresByType image/jpeg "access plus 7 days"
ExpiresByType image/png "access plus 7 days"
ExpiresByType image/x-icon "access plus 7 days"
ExpiresByType image/ico "access plus 7 days"
ExpiresByType text/css "access plus 2 days"
</VirtualHost>
跑步Ubuntu 服务器 Karmic Koala。
答案1
一个选项是将通用配置放在单独的文件中,然后使用包括指令使其在两个VirtualHosts中都使用。