删除 HTML 或 ASPX 扩展 [英] Remove HTML or ASPX Extension

查看:17
本文介绍了删除 HTML 或 ASPX 扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在托管的 IIS7 环境中,我正在寻找使用无扩展名文件名的最简单方法.只是我有以下页面:

In a hosted IIS7 environment, I am looking for the simplest way to use extension-less file names. Simply I have the following pages:

index.html(或 .aspx)--> domain.comGallery.html --> domain.com/galleryvideo.html --> domain.com/videos等等...

index.html (or .aspx) --> domain.com gallery.html --> domain.com/gallery videos.html --> domain.com/videos etc...

我只有几页,没有动态代码,没什么特别的.我发现的所有示例或我在其他网站中使用的方法都围绕动态内容、页面等展开.我只是在寻找最简单的解决方案,理想情况下不需要安装任何类型的 url 重写模块.最好,我可以保留 .html 扩展名,而不是将站点转换为 ASP.NET 项目,但这是一个选项.

I only have a handful of pages, I have no dynamic code, nothing special. All the examples I have found or methods I use in other sites I've developed revolve around dynamic content, pages, etc. I am simply looking for the simplest solution, ideally not requiring any sort of url rewrite module installed. Preferably, I could keep the .html extension instead of converting the site to a ASP.NET project, but that is an option.

谢谢.

推荐答案

我最终使用了以下网站:

I ended up using the following sites:

http://blogs.msdn.com/b/carlosag/archive/2008/09/02/iis7urlrewriteseo.aspx

http://forums.iis.net/t/1162450.aspx

或者基本上是我的 web.config 文件中的以下代码,使用大多数托管站点现在提供的 IIS7 URL 重写模块(在这种情况下我使用的是 GoDaddy):

or basically the following code in my web.config file using the IIS7 URL Rewrite Module that most hosted sites now offer (in this case I am using 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>

这篇关于删除 HTML 或 ASPX 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆