IIS 7.5 url 重写帮助 - 奇怪的查询字符串

发布于 2024-12-11 12:01:52 字数 506 浏览 1 评论 0原文

我有一个入站链接,其中有很多垃圾。我的网站仅加载主页并忽略查询字符串,但我想检测查询字符串并重定向到干净的主页网址。

网址如下所示:

http://www.mysite.url/?c%253E'dmjdlgsbve%253E2'lfzxpset%253E'sbol%253E2'f%253E'vsm%253Eiuuq%253B00xxx%252 Fopdmjdlz%252Fdpn0'gffe%253Eopqbz'qsjdf%253E'tbq%253Ebd7g8g73cc3c7d%253Af5925f3efd2f62dcd'zbsht%253Exxx%252Fopdmjdlz%252Fdpn

我似乎无法制定一条规则来捕获此查询字符串并让我重定向到 http://www.mysite.url。有什么想法吗?

I have an inbound link that has a lot of garbage in it. My site just loads the home page and ignores the querystring, but I'd like to detect the querystring and redirect to a clean home url.

The url looks like this:

http://www.mysite.url/?c%253E'dmjdlgsbve%253E2'lfzxpset%253E'sbol%253E2'f%253E'vsm%253Eiuuq%253B00xxx%252Fopdmjdlz%252Fdpn0'gffe%253Eopqbz'qsjdf%253E'tbq%253Ebd7g8g73cc3c7d%253Af5925f3efd2f62dcd'zbsht%253Exxx%252Fopdmjdlz%252Fdpn

I can't seem to make a rule that catches this querystring and let me redirect to http://www.mysite.url. Any ideas?

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

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

发布评论

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

评论(1

奶茶白久 2024-12-18 12:01:52

这很容易做到。首先,您必须确保您位于主页(即空请求 URL),然后检查条件中是否有非空查询字符串。如果两者都是这种情况,您将永久重定向回相同的 URL(= 没有查询字符串的 URI)。

喜欢:

<rule name="Remove query string" stopProcessing="true">
    <match url="^$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="^$" negate="true" />
    </conditions>
    <action type="Redirect" url="{URL}" appendQueryString="false" />
</rule>

如果您愿意,您可以添加更具体的条件,使其仅匹配此特定的入站链接。

更新:
我怀疑您的 URL 中存在双重 URL 编码。例如,%253E 可能会被替换为 %3E,因为 %25 是百分号 URL 编码。 %3E 是 >字符 URL 编码。所以我认为你会更幸运:

<rule name="Remove query string" stopProcessing="true">
    <match url="^$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="^c%3E'dmjdlgsbve%3E2'lfzxpset%3E'sbol%3E2'f%3E'vsm%3Eiuuq;00xxx/opdmjdlz/dpn0'gffe%3Eopqbz'qsjdf%3E'tbq%3Ebd7g8g73cc3c7d:f5925f3efd2f62dcd'zbsht%3Exxx/opdmjdlz/dpn$" />
    </conditions>
    <action type="Redirect" url="{URL}" appendQueryString="false" />
</rule>

It's pretty easy to do. First of all you have to make sure you are on the homepage (i.e. empty request URL) and then you check for a non empty query string in the conditions. If both are the case, you do a permanent redirect back to the same URL (= URI without query string).

Like:

<rule name="Remove query string" stopProcessing="true">
    <match url="^$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="^$" negate="true" />
    </conditions>
    <action type="Redirect" url="{URL}" appendQueryString="false" />
</rule>

If you want you could add a more specific condition to let it only match this specific inbound link.

UPDATE:
I suspect that there is some double URL encoding going on in your URL. For example, %253E is probably ment to be %3E as %25 is the percentage sign URL encoded. And %3E is the > character URL encoded. So I think you will have more luck with this:

<rule name="Remove query string" stopProcessing="true">
    <match url="^$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="^c%3E'dmjdlgsbve%3E2'lfzxpset%3E'sbol%3E2'f%3E'vsm%3Eiuuq;00xxx/opdmjdlz/dpn0'gffe%3Eopqbz'qsjdf%3E'tbq%3Ebd7g8g73cc3c7d:f5925f3efd2f62dcd'zbsht%3Exxx/opdmjdlz/dpn$" />
    </conditions>
    <action type="Redirect" url="{URL}" appendQueryString="false" />
</rule>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文