【发布时间】:2021-09-05 12:22:06
【问题描述】:
所以我有一个基于 Web 的应用程序,我负责在我们的客户处安装它。这需要在 IIS 中进行大量手动配置,而我几乎可以通过 Powershell 完成所有这些工作。但是我正在努力解决一件关键的事情,那就是我需要应用的 URL 重写设置。我想出的第一个是添加一条规则,将默认网站转发到特定网站。我通过以下方式进行管理:
$filterRoot = "system.webServer/rewrite/rules/rule[@name='RootRedirect$_']"
Clear-WebConfiguration -pspath $site -filter $filterRoot
Add-WebConfigurationProperty -pspath $site -filter "system.webServer/rewrite/rules" -name "." -value @{name='RootRedirect' + $_ ;patternSyntax='Regular Expressions';stopProcessing='True'}
Set-WebConfigurationProperty -pspath $site -filter "$filterRoot/match" -name "url" -value "(^$)"
Set-WebConfigurationProperty -pspath $site -filter "$filterRoot/conditions" -name "logicalGrouping" -value "MatchAny"
Set-WebConfigurationProperty -pspath $site -filter "$filterRoot/action" -name "type" -value "Redirect"
Set-WebConfigurationProperty -pspath $site -filter "$filterRoot/action" -name "url" -value "/redirectedlink"
我要弄清楚的第二个问题是如何将任何传入连接重定向到 https。我知道必须进入的设置,所以我最初的想法是手动创建它,然后使用 Get-WebConfigurationProperty 查看设置在 PowerShell 中的样子,这样我就知道如何重新创建它们了。但我似乎无法弄清楚如何获得它们。我已经使用名称 HTTPSRedirectTest 当前配置了规则,但我不知道如何在 PowerShell 中查看该规则。我找到了有关 Get-WebConfigurationProperty 的各种信息,但找不到与 URL 重写设置相关的任何内容。有人对此有什么建议吗?
【问题讨论】:
标签: powershell https url-rewrite-module