正在从URL IIS重写的末尾删除&PageSpeed=noscript

huwehgph  于 2022-11-12  发布在  其他
关注(0)|答案(3)|浏览(166)

I am trying to remove the last part of the URL with IIS Rewrite, but somewhere I do the things wrong. Example URL: https://example.com/BGLog/pages/register/?ReturnUrl=/blog/arebemagare/site/posts/?bid=37780&PageSpeed=noscript I need to remove &PageSpeed=noscript I wroted rule, but it strips also ?ReturnUrl=/blog/arebemagare/site/posts/?bid=3778 :

<rule name="Remove paging parameters" stopProcessing="true">
<match url="(.*)?$" />
<conditions trackAllCaptures="true">
                    <add input="{QUERY_STRING}" pattern="(.*)(.*)&amp;PageSpeed=noscript(.*)" />
</conditions>
<action type="Redirect" url="{R:1}" appendQueryString="false" redirectType="Temporary" />

Any suggestion? Thanks!

emeijp43

emeijp431#

我想我做到了,但有两条规则:

<rule name="Remove &PageSpeed" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny" trackAllCaptures="true">
                        <add input="{QUERY_STRING}" pattern="(.*)(&amp;PageSpeed=noscript)" />
    </conditions>
    <action type="Redirect" url="{R:1}?{C:1}" appendQueryString="false" redirectType="Found" />
</rule>
<rule name="Remove ?PageSpeed" enabled="true" stopProcessing="true">
  <match url="(.*)?$" />
  <conditions>
                        <add input="{QUERY_STRING}" pattern="(.*)(PageSpeed=.+)(.*)" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
vxbzzdmp

vxbzzdmp2#

请尝试以下规则:

<rewrite>
            <rules>
                <rule name="test" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{QUERY_STRING}" pattern="(.*)&amp;(PageSpeed=noscript)" />
                    </conditions>
                    <action type="Redirect" url="{R:1}?{C:1}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>

我的测试结果是有效的,希望这对你也有效。

xwmevbvl

xwmevbvl3#

它工作了!但是我发现它也捕获了https://example.com/BGLog/blog/filteredlist?cat=5021&PageSpeed=noscript并将其重写为https://example.com/BGLog/blog/filteredlist
我试着编辑它,使其不剥离?cat=5021,但没有成功:(

相关问题