首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重写URL重定向

重写URL重定向
EN

Stack Overflow用户
提问于 2019-11-05 06:19:04
回答 2查看 38关注 0票数 1

我正在尝试从此地址重写URL:

https://merchant.test-01.mysite.co/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD

致此地址:

https://mysite.co/nz/test-01/merchant/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD

我试试这个:

代码语言:javascript
复制
<rule name="test01Generic" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
    </conditions>
    <action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}" redirectType="Found" />
</rule>

结果如下:

https://mysite.co/nz/test-01/merchant?amount=69.90®ister_id=12¤cy=NZD

缺少payment-gateway/vend的地方

还有这个

代码语言:javascript
复制
<rule name="test01Generic" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
    </conditions>
    <action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}{REQUEST_URI}" redirectType="Found" />
</rule>

结果如下:

https://mysite.co/nz/test-01/merchant/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD&amount=69.90®ister_id=12¤cy=NZD

查询参数加倍。

我遗漏了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-06 04:30:25

我能够解决这个问题,我必须将{REQUEST_URI}更改为{PATH_INFO}

代码语言:javascript
复制
<rule name="test01Generic" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
    </conditions>
    <action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}{PATH_INFO}" redirectType="Found" />
</rule>

现在当调用下面的地址时:

https://merchant.test-01.mysite.co/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD

我正在重定向到这个地址:

https://mysite.co/nz/test-01/merchant/payment-gateway/vend?amount=69.90®ister_id=12¤cy=NZD

票数 0
EN

Stack Overflow用户

发布于 2019-11-05 11:17:43

请将{REQUEST_URI}修改为{URL},并将appendQueryStrin保留为true,这样就可以了。

代码语言:javascript
复制
 <rule name="test0Generic" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^(\S+?).test-01.mysite.co$" />
    </conditions>
    <action type="Redirect" url="https://mysite.co/nz/test-01/{C:1}{URL}" appendQueryString="true" redirectType="Found" />
</rule>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58701899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档