IIS - url rewrite: Problem with url rewrite rules not triggering

Pascal Zotto 26 Reputation points
2022-05-24T15:30:47.903+00:00

Hi,

I have some users landing on my page with this url:

https://www.dummydomain.eu/eifeler-regel-letzebuergesch-checker?l=lu

That page does not exist anymore so they redirected to:

https://www.dummydomain.eu/lu/eifeler-regel-letzebuergesch-checker

I set up this rule which does not seem to trigger at all:

                <rule name="RedirectEFChecker" stopProcessing="true">
                    <match url="^(.*)(\/.*)\?l=(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{QUERY_STRING}" pattern="l=([a-z]{2})" />
                    </conditions>
                    <action type="Redirect" url="https://www.dummydomain.eu/{C:1}/{R:2}" appendQueryString="false" />
                </rule>

what did I miss?

The second issue is that I have another rule that should block all traffic aiming at any url that's not part of my domain.

                <rule name="BlockNichtMeins" stopProcessing="true">
                    <match url=".*" negate="true" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{URL}" pattern="\/(de|en|fr|lu)/(admin|agb|dsgvo|eifeler-regel-letzebuergesch(-checker)?|grammar|impressum|index|inhouse|interpunkt|jobs|letzebuergesch-(laenner|verben)|reference|transdata(2|ag)?|translations|verb)$" negate="true" />
                    </conditions>
                    <action type="AbortRequest" />
                </rule>

but it does not work, what did I miss here?

Best regards,
Pascal

Windows development Internet Information Services
0 comments No comments
{count} votes

Accepted answer
  1. Sam Wu-MSFT 7,561 Reputation points Microsoft External Staff
    2022-05-25T02:33:26.817+00:00

    @Pascal Zotto

    I set up this rule which does not seem to trigger at all

    You can try this rule:

     <rule name="test" stopProcessing="true">  
         <match url="^eifeler-regel-letzebuergesch-checker$" />  
            <conditions>  
               <add input="{QUERY_STRING}" pattern="l=([a-z]+)" />  
            </conditions>  
         <action type="Redirect" url="https://www.dummydomain.eu/{C:1}/{R:0}" appendQueryString="false" />  
     </rule>  
    

    The second issue is that I have another rule that should block all traffic aiming at any url that's not part of my domain.

    I couldn’t understand your requirement clearly, please post more details information about your requirement. You'd better give some examples, I will made demo for you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Pascal Zotto 26 Reputation points
    2022-05-25T08:10:02.393+00:00

    Hi @Sam Wu-MSFT ,

    with that rule I now get:

    The expression "https://www.dummydomain.eu/{C:1}/{R:2}" cannot be expanded.

    Regarding the second rule:

    Let's say my domain only has the following pages:

    /index
    /eifeler-regel-letzebuergesch-checker
    /agb
    /dsgvo

    I now want anyone trying to access a non-existent page to be blocked:

    https://www.dummydomain.eu/admin
    https://www.dummydomain.eu/cdn-cgi
    https://www.dummydomain.eu/mysql
    https://www.dummydomain.eu/feed
    https://www.dummydomain.eu/someotherstring
    https://www.dummydomain.eu/

    so the existent ones should be whitelisted any other page blacklisted and thus blocked.

    I hope that explanation helps.

    Br,
    Pascal


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.