URL Rewrite troubleshoot

2019-07-24 02:51发布

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条回答
何必那么认真
2楼-- · 2019-07-24 03:37

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.

查看更多
登录 后发表回答