Set URL Rewrite Rules via appcmd [Answered]RSS

2 replies

Last post Dec 19, 2018 11:50 AM by TheJoeIaut

  • Set URL Rewrite Rules via appcmd

    Dec 18, 2018 02:42 PM|TheJoeIaut|LINK


    I am currently trying to set Rewrite Rules via appcmd and i can't figure out where i go wrong.

    The desired outcome would be:



          <rule name="Client Angular Routes" stopProcessing="true">

            <match url="Client*" />

            <conditions logicalGrouping="MatchAll">

              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />


            <action type="Rewrite" url="Client/index.html" />




    I start of with:

    set config "MyWebApplication" -section:system.webServer/rewrite/rules /+"[name='ClientAngularRoutes', stopProcessing='True']" /commit:""MyWebApplication""

    This correctly adds a new Rule in the rewrite section.

    Here i am stuck. I can't figure out how to add the match tag.

    My command currently looks like this:

    set config "MyWebApplication" -section:system.webServer/rewrite/rules.[name='ClientAngularRoutes'] /match.url:'Client*' /match.ignoreCase:true /commit:""MyWebApplication""

    This command fails with: Unknown config section...

    What am i doing wrong?

  • Re: Set URL Rewrite Rules via appcmd

    Dec 19, 2018 05:14 AM|Jalpa Panchal|LINK

    Hi TheJoeIaut ,

    To add match url in rewrite rule using appcmd use below command:

    • appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].match.url:"(client*)""
    • appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /+"[name='Redirect to HTTPS'].conditions.[input='{REQUEST_FILENAME}',matchType='IsFile']"
    • appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /+"[name='Redirect to HTTPS'].conditions.[input='{REQUEST_FILENAME}',matchType='IsDirectory']"
    • appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].action.type:"Rewrite""
    • appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].action.url:"client/index.html""


    <rule name="Redirect to HTTPS">
    <match url="(client*)" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
    <action type="Rewrite" url="client/index.html" />


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact
  • Re: Set URL Rewrite Rules via appcmd

    Dec 19, 2018 11:50 AM|TheJoeIaut|LINK

    Hello Pancha,

    That worked like a charm. Thank you very much!

    BR TheJoeIaut