我希望仅在域名为 *.example.com 时应用某些规则。我该怎么做?
##start if domain is *.example.com##
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^demo
RewriteRule ^robots\.txt$ robots_allow.txt
##end if domain is *.example.com
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
答案1
我找到了办法
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_HOST} example.com
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^demo
RewriteCond %{HTTP_HOST} example.com
RewriteRule ^robots\.txt$ robots_allow.txt
</IfModule>