Web应用程序的URL重写错误 [英] URL Rewrite error with Web Applications

查看:69
本文介绍了Web应用程序的URL重写错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows Server 2008 R2上使用IIS7运行ASP.NET 4.0网站.

I am running an ASP.NET 4.0 website using IIS7 on Windows Server 2008 R2.

该站点在主域下有许多Web应用程序(〜/site1,〜/site2,〜/site3等).每个Web应用程序都是同一网站源文件夹(D:\ Websites \ MySite)的实例,因此您可以通过以下任何URL访问同一网站:

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

www.mydomain.com/site1

www.mydomain.com/site1

www.mydomain.com/site2

www.mydomain.com/site2

www.mydomain.com/site3

www.mydomain.com/site3

每次都返回相同的网站,但内容有所不同,具体取决于所调用的特定URL.

The same website is returned each time, but with slightly different content depending on which specific URL is called.

一切都工作了好几个月,直到要求我使用URL Rewrite添加一些SEO优化.我添加的每个URL重写规则都会产生以下错误:

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错误500.52-URL重写模块错误.由于发生内部服务器错误,因此无法显示该页面.

HTTP Error 500.52 - URL Rewrite Module Error. The page cannot be displayed because an internal server error has occurred.

配置错误:无法添加类型为规则"的重复集合条目,且其唯一键属性名称"设置为"AddTrailingSlashRule1"

Config Error: Cannot add duplicate collection entry of type 'rule' with unique key attribute 'name' set to 'AddTrailingSlashRule1'

我已经阅读了< system.webServer>周围的其他地方. web.config文件中的configSection带有:

I have read elswhere that surrounding the <system.webServer> configSection in the web.config file with:

<location path="." inheritInChildApplications="false">

将解决此问题.

但是,虽然它阻止了错误消息的出现,但它也阻止了URL重写规则在任何Web应用程序(〜/site1,〜/site2,〜/site3)中的工作.

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).

如何使URL重写模块与Web应用程序一起使用?

How can I get the URL Rewrite module to work with Web Applications?

感谢您可以提供的任何帮助.

Thanks for any help you can offer.

推荐答案

添加一个透明字符以防止子站点上出现重复错误.

Add a clear to prevent the duplicate errors on subsites.

 <rules>
    <clear />
    <rule name="Redirect rule for /maps">
      ....
    </rule>
 </rules>

这篇关于Web应用程序的URL重写错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆