简体   繁体   English

默认文档未正确附加查询字符串

[英]Default Document not appending query string properly

I want to be able to append query string on the default document and re-direct with the query string (append).我希望能够在默认文档上使用 append 查询字符串并使用查询字符串(追加)重新定向。

www.example.com/?test=1 [FAILS] www.example.com/?test=1 [失败]

it takes me to a 404 page not found.它带我到一个 404 页面未找到。 Now the issue is that all other pages will append the query string:现在的问题是所有其他页面将 append 查询字符串:

www.example.com/about?text=1 [WORKS] www.example.com/about?text=1 [作品]

How can I append query string on default document?如何在默认文档上查询 append 字符串?

I was able to partially fix for fb's query string:我能够部分修复 fb 的查询字符串:

<rule name="fb Query String" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{QUERY_STRING}" pattern="^fbclid=" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" appendQueryString="false" redirectType="Found" />

When applied this rule will re-direct:应用此规则时将重定向:

www.example.com/?fbclid=IwAR3FhQ23wiLYsMUl5Mk-CYo_X74nw4-0MVPCpTt20V_KoVtizkOtBGP7TIg www.example.com/?fbclid=IwAR3FhQ23wiLYsMUl5Mk-CYo_X74nw4-0MVPCpTt20V_KoVtizkOtBGP7TIg

to

www.example.com www.example.com

when I set appendQueryString="true" I get ERR_TOO_MANY_REDIRECTS and I also want to match for just the default document page not all URLs as the rule states above: <match url="(.*)" /> Do I match for home.aspx or do I match on the.com because it's the default document?当我设置appendQueryString="true"时,我得到 ERR_TOO_MANY_REDIRECTS 并且我还想匹配默认文档页面而不是所有 URL,如上面的规则所述: <match url="(.*)" />我是否匹配主页。 aspx 还是我匹配.com 因为它是默认文档?

According to your description, it seems you have already implemented redirect the url根据您的描述,您似乎已经实现了 redirect the url

from www.example.com/anytext/anytext?fbclid=1 to www.example.com/?fbclid=1www.example.com/anytext/anytext?fbclid=1www.example.com/?fbclid=1

But the redirect rule also works with other urls which contain more path like www.example.com/about .但是重定向规则也适用于包含更多路径的其他网址,例如www.example.com/about So you tried with the redirect rule fb Query String which you provided above.因此,您尝试使用上面提供的重定向规则fb Query String

In my opinion, you just need to change {R:0} to {QUERY_STRING} and still set appendQueryString with false like below:在我看来,您只需要将{R:0}更改为{QUERY_STRING}并仍然将appendQueryString设置为 false,如下所示:

<rewrite>
  <rules>
    <rule name="rule1" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll">
        <add input="{QUERY_STRING}" pattern="^fbclid=" />
      </conditions>
      <action type="Redirect" url="http://www.example.com/{QUERY_STRING}" appendQueryString="false" redirectType="Found" />
    </rule>
  </rules>
</rewrite>

Then it can implement your requirement.然后它可以实现你的要求。

If I misunderstood your requirements, please let me know.如果我误解了您的要求,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM