url 在 web.config 中重写 [英] url rewrite in web.config

查看:56
本文介绍了url 在 web.config 中重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关 web.config 中的 Url Rewrite 的文章,但我不明白为什么我的重定向不起作用.以下是我的示例网址:

I've been reading articles regarding Url Rewrite in web.config but I don't understand why my redirection doesn't work. Below is my sample url:

localhost/MySite/1542

这是我用来匹配网址的模式:

and here's the pattern I used for matching the url:

<rule name="testRedirect" stopProcessing="true">
   <match url="^/MySite/([0-9]+)" />
   <action type="Redirect" url="/MySite/default.html" />
</rule>

有人能告诉我我的代码有什么问题吗?

can someone enlighten me what's wrong with my code?

推荐答案

尝试删除匹配 url ^MySite/([0-9]+) 中的前导 /

try removing the leading / in matching url ^MySite/([0-9]+)

<rule name="testRedirect" stopProcessing="true">
   <match url="^MySite/([0-9]+)" />
   <action type="Redirect" url="/MySite/default.html" />
</rule>

这篇关于url 在 web.config 中重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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