iis - IIS URL重写为html而不是同名的子目录
问题描述
我在 IIS 上的 jekyll 生成的静态网站指向子目录,而不是同名的实际 html 文件(都在根目录中)。我如何能够更改 web.config 以便它将重定向/重写到 html?
我正在 IIS 上部署一个 jekyll 生成的静态网站。我已经搜索了互联网,现在 URL 不需要默认的 .html 扩展名。我在 Web.Config 中使用了以下代码来删除 html 扩展名:
<rule name="Redirect to clean URL" enabled="true" stopProcessing="true">
<match url="^([a-z0-9/]+).html$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="RewriteHTML" enabled="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.html" />
</rule>
这是我的根示例:
-----
|---
|---
| |---1.html
|---/sub---|---2.html
| |---3.html
|
|---index.html
|
|---sub.html
|
|
|---noExtension.html
|
|
|
-----
我现在所取得的成就是:
http://www.example.com/ =====> index.html
http://www.example.com/noextension =====> noextension.html
http://www.example.com/sub =====> /sub ** 代替 sub.html **
http://www.example.com/sub/1 =====> /sub/1.html
我希望将 urlhttp://www.example.com/sub
定向到 sub.html 而不是目录。
** PS 我不认为我可以更改文件结构,因为它是由 jekyll 生成的。并且需要 IIS。没有 Apache/nginx **
如果有人可以帮助我,那将是合适的!
干杯!
解决方案
推荐阅读
- android - 三星 Galaxy s9 能否将其操作系统从 10 升级到 11?
- nginx - nginx 上 docker 中的 Wordpress - 502 Bad Gateway
- javascript - Prisma with Next-Auth,用户创建失败导致Keycloak的api响应键名
- python-3.x - 安装 Wordcloud for Python 等包:要安装哪些工具?
- python - 如何添加十六进制字符串列表以获得总十六进制值
- jenkins - 参数化远程触发器正在阻止作业,直到远程作业被触发
- c++ - C ++在没有其他库的位图图像上绘制文本
- azure-cosmosdb - Azure Cosmos + EF Core 3.1 问题与 LocaView.Remove 和后续 Context.SaveChangeAsync()
- php - 检查字符串是否包含 2 个数组中的值
- flutter - 如何从可拖动的孩子触发拖动事件