You can follow some of the below patterns to support different environments through same set of configuration files.
www_example_com.vhost
<VirtualHost *:80>
ServerAlias "
www.example.com" "exampledotcom-dev.test.com" "exampledotcom-uat.test.com" "exampledotcom-stage.test.com"
....
<Location />
<If "'${ENV_TYPE}' =~ m#(dev|uat|stage)#">
....
</If>
</Location>
</VirtualHost>
Also in rewrite file use variables to support environment specific redirects(may be vanity redirect you can keep the live URL)
www_example_com.rules
e.g
RewriteRule ^/$ %{HTTP:X-Forwarded-Proto}://%{SERVER_NAME}/us/en/home.html [R=301,L]
RewriteRule "^/test$" "%{HTTP:X-Forwarded-Proto}://%{SERVER_NAME}/test_page.html" [R=301,NC,NE,L]
Also in available farms, virtualhost configuration
www_example_com.farm
/virtualhosts {
"exampledotcom-dev.test.com"
"exampledotcom-uat.test.com"
"exampledotcom-stage.test.com"
}
The
ENV_TYPE variable is predefined in AMS, and its value can be customized by coordinating with an Adobe CSE. AEM as a Cloud Service introduces the
ENVIRONMENT_TYPE variable, with possible values being 'development' (irrespective of the number of development environments enabled or their designated purposes), 'stage', or 'production'. Additionally, AEM as a Cloud Service provides flags such as
ENVIRONMENT_DEV,
ENVIRONMENT_STAGE, and
ENVIRONMENT_PROD. Custom variables can be defined within global or environment-specific variable files. Furthermore, AEM as a Cloud Service allows the use of variables defined in the Cloud Manager within dispatcher configurations, refer to
https://www.albinsblog.com/2023/09/support-custom-run-modes-in-aem-as-a-cloud-env-specific-values.html for more details.
Regards
Albin