I have a set of apache (2.4.25) sites that use mod_vhost_alias so the one vhost services multiple subdomains.
I want to be able to set a environment variable, say
<VirtualHost _default_:443>`
ServerNameAlias *.whatever-it-is.com
SetEnv HOME_URL https://www.whatever-it-is.com/
# etc
then in my various sites .htaccess files pick up that variable. So a site might allow access to a subfolder or a specific file and redirect everything back to the home site.
php_flag engine off
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/?
RewriteCond %{REQUEST_URI} !^/myapp[/]?
RewriteCond %{REQUEST_URI} !^favicon.ico
RewriteRule (.*) %{HOME_URL} [R=301,L]
# ^--- not working, how would you do it?
then in the case where I need to change the home_url across all sites, I can just apply it in the vhost and each of the dozens of subdomain sites will pick it up.
* also tried
RewriteRule (.*) %{ENV:HOME_URL} [R=301,L]
http://httpd.apache.org/docs/2.0/env.html The %{ENV:variable} form of TestString in the RewriteCond allows mod_rewrite's rewrite engine to make decisions conditional on environment variables...