问题
I am running an ASP.NET 4.0 website using IIS7 on Windows Server 2008 R2.
The site has a number of Web Applications under the main domain (~/site1, ~/site2, ~/site3, etc...). Each Web Application is an instance of the same website source folder (D:\Websites\MySite), so you can access the same website at any of the following URLs:
www.mydomain.com
www.mydomain.com/site1
www.mydomain.com/site2
www.mydomain.com/site3
The same website is returned each time, but with slightly different content depending on which specific URL is called.
Everything has been working fine for months until I was asked to add some SEO optimizations using URL Rewrite. Every URL Rewrite rule I add produces the following error:
HTTP Error 500.52 - URL Rewrite Module Error. The page cannot be displayed because an internal server error has occurred.
Config Error: Cannot add duplicate collection entry of type 'rule' with unique key attribute 'name' set to 'AddTrailingSlashRule1'
I have read elswhere that surrounding the <system.webServer> configSection in the web.config file with:
<location path="." inheritInChildApplications="false">
will fix this problem.
However, while it stops the error message from appearing, it also stops the URL Rewrite rules from working in any of the Web Applications (~/site1, ~/site2, ~/site3).
How can I get the URL Rewrite module to work with Web Applications?
Thanks for any help you can offer.
回答1:
Add a clear to prevent the duplicate errors on subsites.
<rules>
<clear />
<rule name="Redirect rule for /maps">
....
</rule>
</rules>
来源:https://stackoverflow.com/questions/14250842/url-rewrite-error-with-web-applications