-2

I am looking to only apply certain rules if domain is *.example.com. How can I do this?

##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>
Chris Muench
  • 417
  • 3
  • 9
  • 29

1 Answers1

0

I have found a way

<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>
Chris Muench
  • 417
  • 3
  • 9
  • 29