【发布时间】:2014-01-11 18:36:22
【问题描述】:
我正在尝试使用重写规则将特定页面重定向到另一个页面。但是,当我在 Web 配置中添加以下代码时,我会收到 500 内部服务器错误。
<rewrite>
<rules>
<clear />
<rule name="New Rewrite" enabled="true">
<rule name="Redirect" stopProcessing="true">
<match url="http://www.mydomain.com/terms" />
<action type="Redirect" url="http://www.mydomain.com/" redirectType="Permanent"/>
</rule>
</rule>
</rules>
</rewrite>
我对重定向不太了解,但是我正在做的是,假设我有一个域www.mydomain.com,如果我有一个特定的 url www.mydomain.com/terms 我需要将它重定向到主页,即@987654324 @
更新
我已经更改了给定的重写规则,仍然可以访问页面条款。第一部分将 www 添加到基于非 www 的 url 工作正常,但不确定第二条规则有什么问题。
<rewrite>
<rules>
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="news redirect" stopProcessing="true">
<match url="/terms" ignoreCase="true"/>
<conditions>
<add input="{HTTP_HOST}" pattern="domain\.com$" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:1}" />
</rule>
</rules>
</rewrite>
【问题讨论】:
标签: .htaccess iis redirect web-config http-status-code-301