URL重写疑难解答 [英] URL Rewrite troubleshoot
问题描述
我们将URL重写如下.我在IIS 8.5 URL Rewrite中测试了该模式,并根据需要匹配了这些模式.但是,每次都为404.有人可以看看我的URL重写有什么问题吗?谢谢.
We have our URL rewrite as followed. I tested the pattern in IIS 8.5 URL Rewrite and the patterns matched as what we wanted. However, it's 404 every single time. Will someone take a look and see what is wrong with my URL rewrite? Thank you.
URL:devbox.mysite.com/article/how-to-use-onedrive
URL: devbox.mysite.com/article/how-to-use-onedrive
模式:(.*)/article/(.*)$
操作重写URL:{R:1}/article/?artID={R:2}
Pattern: (.*)/article/(.*)$
Action Rewrite URL: {R:1}/article/?artID={R:2}
当前页面显示404.下面是web.config文件中的XML代码.
Currently the page shows 404. Below is the XML code in web.config file.
<rule name="Article-rewrite" enabled="true">
<match url="(.*)/article/(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="{R:1}/article/?artID={R:2}" appendQueryString="false" />
</rule>
推荐答案
尝试一下:
<rule name="Article-rewrite" enabled="true">
<match url="article/(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="article/?artID={R:1}" appendQueryString="false" />
</rule>
我已从匹配网址中删除了该域,因为您没有切换域.
I've removed the domain from the match url, as you're not switching the domain.
这篇关于URL重写疑难解答的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!