gpt4 book ai didi

powershell - 如何通过 Powershell 设置 IIS 自定义错误?

转载 作者:行者123 更新时间:2023-12-03 11:20:25 25 4
gpt4 key购买 nike

我正在尝试弄清楚如何使用 Powershell 为错误 401 设置 IIS 自定义错误,所以我试过了但没有成功。

Set-WebConfigurationProperty -Filter "/system.webServer/httpErrors/error[@statusCode='401']" -Location IIS:\Sites\MySite -Name path -Value "~/Content/CustomErrors/401.html"

我要实现这个配置结果

Desired configuration

提前致谢。

最佳答案

经过长时间的尝试错误循环,我终于想出了解决办法,如果有人感兴趣,我将向您展示我的解决方案。

Set-Location IIS:\Sites\MySite

add-WebConfiguration -Filter /System.WebServer/HttpErrors -Value @{StatusCode=401;PrefixLanguageFilePath="$Null"; Path="~/Content/ErrorMessages/401.html"; ResponseMode="ExecuteURL"}

关于powershell - 如何通过 Powershell 设置 IIS 自定义错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37466768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com