powershell - PowerShell URL 从根目录重定向到子目录
问题描述
我正在尝试在 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"}
解决方案
忘记在下面添加 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"
推荐阅读
- c - 在 mpi 中处理计算和通信的过程
- mongodb - mongodb中的“用指南针连接”和“用mongo shell连接”有什么区别?
- rust - 如何在 Rust 中从特定索引开始的子字符串中查找?
- flask-sqlalchemy - AttributeError:“dict”对象没有属性“save_to_db”0
- javascript - 如何从可组合文件中获取响应值到 setup() 方法中?
- rust - 如何在 Rust 中将 ref 转换为枚举值作为 u16(基本枚举类型)?
- css - NextJS 项目中的样式 JSX 不适用于外部(antd)组件
- android - Android Media Recorder 输出文件大小 0KB
- python - 如何将具有逗号分隔符的 CSV 文件转换为只有空格分隔符的 csv
- java - 是否有任何可用于 docusign 的 java 和 Spring Boot 集成示例源代码?