使用查询字符串和问号 IIS 7 重写 IIS

发布于 2024-11-09 23:49:44 字数 741 浏览 0 评论 0原文

我已经阅读了这些线程,但仍然无法解决,我知道我的问题,但想知道是否可以为我指明正确的方向。

我设置了一个规则:

www.mydomain.com/productlist.asp?CategoryID=2

重写为

www.mydomain.com/homeware/cushions

.

            <rule name="cushions">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="productlist.asp?CategoryID=2" />
            </rule>

好的,现在我的问题是结果的分页,所以当用户进入下一页时原始域看起来像:

www.mydomain.com/productlist.asp?CategoryID=2&Page=2

这就是我遇到问题的地方 - 我希望它变成:

www.mydomain.com/homeware/cushions?page=2

并持续多少页 只是无法让它工作 - 我知道我需要使用查询字符串,但真的很挣扎。求专业知识,感谢帮助

I have read the threads and I still can't work it out, my problem I know, but wondering if could point me in the right direction.

I have setup a rule:

www.mydomain.com/productlist.asp?CategoryID=2

rewritten to

www.mydomain.com/homeware/cushions

.

            <rule name="cushions">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="productlist.asp?CategoryID=2" />
            </rule>

ok, now my problem is with pagination of the results, so the original domain when the user goes onto the next page would look like:

www.mydomain.com/productlist.asp?CategoryID=2&Page=2

This is where I'm having problems - I want this to become:

www.mydomain.com/homeware/cushions?page=2

and ongoing for how many pages
just can't get it to work - I understand I need to use query string but really struggling. Asking for expertise, thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱人配狗天长地久 2024-11-16 23:49:45

要捕获查询字符串,您需要使用条件,因为匹配 URL 不包含它。
所以你可以用如下规则来做到这一点:

<rule name="cushions" stopProcessing="true">
<match url="^homeware/cushions$" />
<conditions>
    <add input="{QUERY_STRING}" pattern="page=(\d+)" />
</conditions>
<action type="Rewrite" url="productlist.asp?CategoryID=2&page={C:1}" appendQueryString="false" /> 

To capture the Query String you need to use conditions for that since the match URL does not include it.
So you could do that with a rule like:

<rule name="cushions" stopProcessing="true">
<match url="^homeware/cushions$" />
<conditions>
    <add input="{QUERY_STRING}" pattern="page=(\d+)" />
</conditions>
<action type="Rewrite" url="productlist.asp?CategoryID=2&page={C:1}" appendQueryString="false" /> 

酷炫老祖宗 2024-11-16 23:49:45

只需在操作中添加appendQueryString =“true”就会自动附加查询字符串。

<rewrite>
        <rules>
            <rule name="test">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="/test/test.cfm?category=5" appendQueryString="true" />
                <conditions>
                </conditions>
            </rule>
        </rules>
    </rewrite>

http://localhost:8081/homeware/cushions?page=2
您将在 URL 变量中收到值为 2 的页面。

Just add appendQueryString="true" in action will automatically append query string.

<rewrite>
        <rules>
            <rule name="test">
                <match url="^homeware/cushions" />
                <action type="Rewrite" url="/test/test.cfm?category=5" appendQueryString="true" />
                <conditions>
                </conditions>
            </rule>
        </rules>
    </rewrite>

http://localhost:8081/homeware/cushions?page=2
You will receive page in URL variable with value 2.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文