我已经设置了一个 apache 服务器,这个 apache 服务器指向一堆虚拟主机。
虚拟主机的定义如下,
<VirtualHost *:80>
ServerName <url>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
# Enable client-side caching of resources
ExpiresActive On
ExpiresByType image/png "now plus 48 hours"
ExpiresByType image/jpeg "now plus 48 hours"
ExpiresByType image/gif "now plus 48 hours"
ExpiresByType application/javascript "now plus 48 hours"
ExpiresByType application/x-javascript "now plus 48 hours"
ExpiresByType text/javascript "now plus 48 hours"
ExpiresByType text/css "now plus 48 hours"
</VirtualHost>
.
.
.
<VirtualHost *:80>
ServerName <url>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
# Enable client-side caching of resources
ExpiresActive On
ExpiresByType image/png "now plus 48 hours"
ExpiresByType image/jpeg "now plus 48 hours"
ExpiresByType image/gif "now plus 48 hours"
ExpiresByType application/javascript "now plus 48 hours"
ExpiresByType application/x-javascript "now plus 48 hours"
ExpiresByType text/javascript "now plus 48 hours"
ExpiresByType text/css "now plus 48 hours"
</VirtualHost>
我有大量类似于上面显示的示例的虚拟主机定义。
由于除 之外的大多数定义ServerName
都是相同的,我想知道是否有办法在全球范围内定义这些通用定义。
我是 apache 配置的新手,我觉得随着虚拟主机定义数量的增加,我的配置文件变得更长和多余。