Changing IIS URL Rewrite config location
When used at site level, the IIS7 URL Rewrite 2 module saves its configuration 开发者_StackOverflow中文版in the web.config file of that site. I'm using Sitecore CMS, and best practice is to store any web.config customisations in a separate config file for ease of upgrading, staging/production setups etc.
Is there any way to specify a different config file for IIS7 redirects?
I know that application-level rewrites are stored in ApplicationHost.config, but I have several sites running on the server and would like to keep them separated.
Thanks, Adam
In order to support this best practice you've mentioned, Sitecore implements pluggable configs, but only for the elements inside <sitecore>
section of web.config. So, unless IIS7 URL rewrite provides some way to move its stuff to a separate config (like ASP.NET does for connectionstrings.config), I'm afraid you'll have to keep it in the main web.config file.
Sorry if I'm saying obvious things.
You can also try to use rewrite maps
<rewrite>
<rewriteMaps configSource="rewriteMaps.config" />
</rewrite>
Sample rewriteMaps.config file:
<rewriteMaps>
<rewriteMap name="CustomRewrites" defaultValue="">
<add key="/instructions" value="/documents" />
</rewriteMap>
</rewriteMaps>
I'm not familiar with the url rewriting config, but I have an example of moving the url mapping to a separate file:
<urlMappings configSource="config\urlMappings.config"></urlMappings>
And that file looks like the following:
<?xml version="1.0"?>
<urlMappings enabled="true">
<add url="~/somedealer" mappedUrl="/?theme=4" />
<add url="~/someotherclient" mappedUrl="/?theme=12" />
</urlMappings>
I'm sure the url rewriting works the same way.
精彩评论