URL Rewrite troubleshoot

我与影子孤独终老i 提交于 2019-12-11 13:43:13

问题


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

Pattern: (.*)/article/(.*)$
Action Rewrite URL: {R:1}/article/?artID={R:2}

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>

回答1:


Try this:

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



来源:https://stackoverflow.com/questions/35464917/url-rewrite-troubleshoot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!