我的 web.config 文件犯了什么错误?
What mistake am I making with my web.config file?
所以我需要从我网站上的网址末尾删除 .html
这是我第一次使用 web.config 我想我可能犯了一个愚蠢的错误,所以这是我到目前为止所做的一切。
- 我创建了一个名为 web.config
的文件
-我将其粘贴到:
<configuration>
<system.webServer>
<rewrite> `
<rules>
<rule name="RewriteHTML">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
- 然后我将它添加到我网站的根目录(httpdocs 上面的文件夹)。什么都没发生。我也尝试将它添加到 httpdocs 中。
我做错了什么?
根据此博客 post :https://www.saotn.org/iis-url-rewrite-hide-php-extension/ - 您做的一切都正确。但实际上你所做的配置 - 而不是删除扩展本身。它只允许您在末尾键入“.html”的情况下导航 URL。尝试使用该博客 post 中描述的第二种方法 - 能够删除请求中的“.html”扩展名。
所以我需要从我网站上的网址末尾删除 .html 这是我第一次使用 web.config 我想我可能犯了一个愚蠢的错误,所以这是我到目前为止所做的一切。
- 我创建了一个名为 web.config 的文件
-我将其粘贴到:
<configuration>
<system.webServer>
<rewrite> `
<rules>
<rule name="RewriteHTML">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>
- 然后我将它添加到我网站的根目录(httpdocs 上面的文件夹)。什么都没发生。我也尝试将它添加到 httpdocs 中。
我做错了什么?
根据此博客 post :https://www.saotn.org/iis-url-rewrite-hide-php-extension/ - 您做的一切都正确。但实际上你所做的配置 - 而不是删除扩展本身。它只允许您在末尾键入“.html”的情况下导航 URL。尝试使用该博客 post 中描述的第二种方法 - 能够删除请求中的“.html”扩展名。