Mod_rewrite to check the maintenance page, with the exception of certain subdomains

I configured Apache to look for a service page and redirect to this page if one is present:

RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.
RewriteRule ^.*$ /system/maintenance.html [L]

This is a pretty standard practice for deploying Ruby on Rails applications.

What I would do is to create a URL list of exceptions to the redirect does not hold for some sub-domains, for example: https://user1.myapp.com/any_request_urlorhttps://user2.myapp.com/any_request_url

Can this be done with additional instructions RewriteCond?

+3
source share
1 answer

This should do it:

RewriteCond %{HTTP_HOST} !^(user1|user2)\.myapp\.com$
+4
source

Source: https://habr.com/ru/post/1704964/


All Articles