我希望使用appcmd创建urlrewrite url,用于重定向来自
http://
至
https://
我试着搜索但什么也没找到。你能给我举一些基本的例子吗?
发布于 2013-10-02 07:48:05
让它和这个一起工作:
appcmd.exe set config -section:system.webServer/rewrite/rules /+"[name='http_redirect',enabled='True']" /commit:apphost
appcmd.exe set config -section:system.webServer/rewrite/rules.[name='http_redirect'] /match.url:"(.*)" /match.ignoreCase:true /commit:apphost
appcmd.exe set config -section:system.webServer/rewrite/rules.[name='http_redirect'].conditions/add /+"[input='{HTTPS}',pattern='off']" /commit:apphost
appcmd.exe set config -section:system.webServer/rewrite/rules.[name='http_redirect'].action /+"[type='Redirect',url='https://{HOST_NAME}/{R:1}',redirectType='Found']" /commit:apphost此链接可以帮助构建appcmd脚本。
发布于 2015-01-15 14:36:08
为了其他人的利益(像我一样),您可以执行以下操作,在列表中的开始、结束或特定位置插入新规则,因为在默认情况下将其添加到末尾可能会导致规则未被击中:
appcmd.exe set config -section:system.webServer/rewrite/rules /+"[@start,name='http_redirect',enabled='True']" /commit:apphost
appcmd.exe set config -section:system.webServer/rewrite/rules /+"[@end,name='http_redirect',enabled='True']" /commit:apphost
appcmd.exe set config -section:system.webServer/rewrite/rules /+"[@2,name='http_redirect',enabled='True']" /commit:apphost来源:
appcmd.exe set config /?发布于 2019-01-22 00:10:15
在我的例子中,语法略有不同,因为我想在根(服务器)级别修改URL重写规则。
appcmd set config -section:system.webServer/rewrite/globalRules -[name='myRule'].action.url:http://myRewrite /commit:apphost我花了很长时间才找出了globalRules,而不是规则上的差异。
https://stackoverflow.com/questions/19091661
复制相似问题