0

I have 2 URL redirection rules:

<rewrite>
    <rules>
        <clear />
        <rule name="al - helyek/al (kieg)" enabled="true" stopProcessing="true">
            <match url="^test1/al/(.*)RootFolder=%2Ftest1(.*)" />
            <action type="Redirect" url="helyek/al/{R:1}RootFolder=%2Fhelyek{R:2}" />
        </rule>
        <rule name="al - helyek/al" enabled="true" stopProcessing="true">
            <match url="^test1/al/(.*)" />
            <action type="Redirect" url="helyek/al/{R:1}" />
        </rule>
    </rules>
</rewrite>

But the first doesn't work, only the second.

Test URL: http://test:29001/test1/al/Megosztott%20dokumentumok/Forms/AllItems.aspx?RootFolder=%2Ftest1%2Fal%2FMegosztott%20dokumentumok%2FTeszt&FolderCTID=0x01200077BA4D1F1CDCF3498096871FD748FB37&View=%7B70C95A37%2D4FE1%2D4A60%2DA100%2D61E529A1DB56%7D

This is a SharePoint Site Collection.

What could be the problem?

David Buck
  • 3,752
  • 35
  • 31
  • 35
  • Query strings are not processed by `match` tag. Use FRT to learn more, https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules – Lex Li May 12 '21 at 17:33

2 Answers2

0

According to your description, RootFolder seems to be the content in the query string. If you need to match the content in the query string, you need to use the server variable {querystring} to match it.

This has a similar issue:

IIS URL Rewrite not working with query string

Ding Peng
  • 3,702
  • 1
  • 5
  • 8
0

I found correct redirect:

<rule name="WEBHELY - helyek/WEBHELY (RootFolder)" stopProcessing="true">
    <match url="^WEBHELY/(.*)" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="(.*)?RootFolder=%2FWEBHELY(.*)" />
    </conditions>
    <action type="Redirect" url="helyek/WEBHELY/{R:1}?RootFolder=%2Fhelyek%2FWEBHELY{C:2}" appendQueryString="false" />
</rule>
<rule name="WEBHELY - helyek/WEBHELY" stopProcessing="true">
    <match url="^WEBHELY/(.*)" />
    <action type="Redirect" url="helyek/WEBHELY/{R:1}" />
</rule>