locked
URL Rewrite via appcmd.exe RRS feed

  • Question

  • User1612823331 posted

    I am using the gui to create some general server-level rewrites that work with my application running on 160 websites, but need some site-specific rewrites as well.

    I found some sample code to do redirects, below, but nothing for rewrites:

    appcmd.exe set config "site name" -section:system.webServer/rewrite/rules /+"[name='http_redirect',enabled='True']" /commit:apphost
    appcmd.exe set config "site name" -section:system.webServer/rewrite/rules.[name='http_redirect'] /match.url:"(.*)" /match.ignoreCase:true /commit:apphost
    appcmd.exe set config "site name" -section:system.webServer/rewrite/rules.[name='http_redirect'].conditions/add /+"[input='{HTTPS}',pattern='off']" /commit:apphost
    appcmd.exe set config "site name" -section:system.webServer/rewrite/rules.[name='http_redirect'].action /+"[type='Redirect',url='https://{HOST_NAME}/{R:1}',redirectType='Found']" /commit:apphost
    

    Can anyone lead me to where I could run such scripts for rewriting, as well as deleting named rules in case a specific rule needs rewriting or removal?

    Wednesday, June 11, 2014 10:36 AM

Answers

  • User-76669496 posted

    Hi,

    Try using the Configuration Editor:

    http://ruslany.net/2008/07/scripting-url-rewrite-module-configuration/

    http://www.iis.net/learn/manage/managing-your-configuration-settings/using-configuration-editor-generate-scripts

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, June 11, 2014 5:52 PM