Planning to migrate to containers, wanted to maintain a single web.config
file by using config builder all the app settings are being handled through environment variables along with this we have rewrite rules for redirection where we've different redirection rules for each environment and these are moved to a separate file like DevRewriteRules.config
, QARewriteRules.config
and ProdRewriteRules.config
by referring the following blog and now our config file for rewrite section in web.config looks as below. Now in the below highlighted section, I want the rewrite rule config file to be changed based on the environment using the environment variable. Please suggest any better way to achieve this scenario.
Add a comment
|
1 Answer
Sitecore has Rule-based configuration.
But, the limitation is that these rules works only under sitecore
node.
That is why, the best way to achieve it will be good old xdt:Transform
.
I suggest you to have X different rewrite rules files:
ProdRewriteRules.config
UatRewriteRules.config
DevRewriteRules.config
And transofrmation files for each of environment:
web.prod.config
web.uat.config
web.dev.config
These files should rule to update rules file, similar to this:
<rules configSource="ProdRewriteRules.config" xdt:Transform="SetAttributes">
and you should run proper XDT transformation before deployment to each environment.
-
Thanks @Anton for the response but I'm looking for a solution using environment variables with the help of config builders. Mar 8, 2023 at 13:06
-
-
1You can consider tokens in web.config and replace the tokens with actual values in your deployment pipelines Aug 6, 2023 at 11:51
-
I totally agree with @SitecorePro , Check this stackoverflow.com/questions/52432799/… Aug 7, 2023 at 5:53