asp.net – 在web.config文件中设置重定向

我试图重定向一些不友好的urls与更具描述性的。这些URL以.aspx?cid = 3916结尾,每个类别名称页面的最后一位数字不同。我想要它改为重定向到Category / CategoryName / 3916。我试过这个在web.config文件:

<location path="Category.aspx?cid=3916">
<system.webServer>
  <httpRedirect enabled="true" destination="http://www.site.com/Category/CategoryName/3916" httpResponseStatus="Permanent" />
</system.webServer>

但由于它并没有结束只是扩展,它没有工作。有没有一个简单的方法来让这个工作?我使用IIS 7.5。

解决方法

>在旧页面所在的目录中打开web.config

>然后为旧位置路径和新目标添加代码如下:

<configuration>
  <location path="services.htm">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://domain.com/services" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
  <location path="products.htm">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://domain.com/products" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>

您可以根据需要添加任意数量的位置路径。

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。