PowerShell URL 从根目录重定向到子目录

PowerShell URL redirect from root to subdirectory

我正在尝试在 PowerShell 中构建部署脚本,以取代使用 IIS 用户界面的手动工作(这是针对 Docker 容器)。我找不到的一步是如何将用户从根 url 导航到应用程序文件夹。因此,如果用户导航到 www.site.com,他们会转到 www.site.com\WebSampleTest.

这是我目前拥有的:

Set-WebConfiguration system.webServer/httpRedirect "IIS:\sites\Default Web Site" -Value @{enabled="true";destination="WebSampleTest";exactDestination="true";httpResponseStatus="Permanent"}

尝试使用这个:

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/httpRedirect" -name "enabled" -value "True"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/httpRedirect" -name "destination" -value "websampletest"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/httpRedirect" -name "httpResponseStatus" -value "Permanent"

忘记添加下面的 WindowsFeature:

Add-WindowsFeature Web-Http-Redirect

然后为实际重定向添加以下代码:

Set-WebConfigurationProperty -pspath 'IIS:\sites\Default Web Site'  -filter "system.webServer/httpRedirect" -name "enabled" -value "True"
Set-WebConfigurationProperty -pspath 'IIS:\sites\Default Web Site'  -filter "system.webServer/httpRedirect" -name "destination" -value "WebSampleTest"
Set-WebConfigurationProperty -pspath 'IIS:\sites\Default Web Site'  -filter "system.webServer/httpRedirect" -name "childOnly" -value "true"