在托管的 IIS7 环境中,我正在寻找使用无扩展名文件名的最简单方法。只是我有以下页面:
index.html
(或.aspx
)-->example.com
gallery.html
-->example.com/gallery
videos.html
-->example.com/videos
- 等...
我只有几页,没有动态代码,没什么特别的。我发现的所有示例或我在我开发的其他站点中使用的所有方法都围绕动态内容、页面等展开。我只是在寻找最简单的解决方案,理想情况下不需要安装任何类型的 URL 重写模块。我最好保留 .html
扩展名,而不是将站点转换为 ASP.NET 项目,但这是一个选项。
最佳答案
我最终使用了以下网站:
http://blogs.msdn.com/b/carlosag/archive/2008/09/02/iis7urlrewriteseo.aspx
和
http://forums.iis.net/t/1162450.aspx
或者基本上我的 web.config 文件中的以下代码使用大多数托管网站现在提供的 IIS7 URL 重写模块(在本例中我使用的是 GoDaddy):
<system.webServer>
<rewrite>
<rules>
<rule name="RewriteASPX">
<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}.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
关于asp.net - 删除 HTML 或 ASPX 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4481632/