aspx转化为html(伪静态)
2011-04-11 01:45
183 查看
运行PHP,ASP.NET,JSP,ColdFusion的网页服务器(如IIS,Apache),大多可以用 URL Rewriting来实现隐藏或改变拓展名。大网站,像腾讯,百度(用PHP),都在用URL Rewriting的方法来把拓展名隐藏或改变。好处有几点: 1. 搜索引擎比较喜欢.html,.htm的(与.jsp,.php,.aspx,.cff相比),因为.html, .htm是静态的,更容易让引擎了解你网页的内容。而动态网页的内容是根据用户,来输出不同的内容,不容易让引擎吸收具体HTML内容。
2. 如果不用URL Rewriting将拓展名隐藏或改成.html,那么假如这个网站要换个技术或把动态页面换成静态,则需要寻找所有含有拓展名的连接,把连接所含URL进行拓展名修改(如从JSP换到PHP技术,则要寻找所有含有.jsp的页面,并把所有含.jsp的URL改成.php,费时费力)。URL Rewriting正好避免了这点,因为好的URL是能做到“不变应完变”的。
3. 防止某些黑客恶意攻击。有些大网站采用不同的技术开发不同功能的页面。而把拓展名改掉,让黑客无法确认此页面用的技术是什么,从而就无从下手。
4. 方便访问者使用。访问者不是程序员,他们不明白什么是.jsp,.php.aspx,他们只知道URL。所以统一把拓展名拿掉,或者同意把拓展名换为html,htm,有利于用户的使用。用户可以知道现在在你网站的位置,如何通过输入URL到某一页面。
实例:
Intelligencia.UrlRewriter.dll aspx重写为html实例
1、http://urlrewriter.net/ 下载解压缩后把Intelligencia.UrlRewriter.dll 文件添加引用到web工程里。
2.web.config配置:
<configSections>
<!--UrlRewriter-->
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<!--UrlRewriter-->
<httpModules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter" />
</httpModules>
</system.web>
</system.web>
<!--UrlRewriter-->
<rewriter>
<rewrite url="~/test_([a-zA-Z]+).html$" to="~/Show.aspx?Code=$1" processing="stop" />
</rewriter>
其中: <rewrite url="~/test_([a-zA-Z]+).html$" to="~/Show.aspx?Code=$1" processing="stop" />
若果code= abc的话,最终显示的结果为"虚拟目录名称/test_abc.html" 。如果吧.html替换成 .aspx那就是"虚拟目录名称/test_abc.aspx"
3.IIS配置:
如果是用"虚拟目录名称/test_abc.aspx" 的话,不需要配置IIS. 使用了"虚拟目录名称/test_abc.html" 配置IIS的方法如下: http://urlrewriter.net/index.php/support/installation/windows-server-2003/ 里面的图9不准确,准确的为:
还有第八步中的”untick Verify that file exists.“要看仔细。否则重写HTML就无效。
4:备注
不要在"应用程序扩展"里“添加" .html的映射,否则正常的html将无法访问。
5.在vs2005中,传多个参数应该加&在vs2003中,只用分号就好了
eg.
<RewriterConfig>
<Rules>
<RewriterRule>
<!--CreditNews BackGround update-->
<LookFor>~NewsClsManage-(\d*)-(\d*).html</LookFor>
<SendTo>~NewsClsManage.aspx?ClassID=$1&flag=$2</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
2. 如果不用URL Rewriting将拓展名隐藏或改成.html,那么假如这个网站要换个技术或把动态页面换成静态,则需要寻找所有含有拓展名的连接,把连接所含URL进行拓展名修改(如从JSP换到PHP技术,则要寻找所有含有.jsp的页面,并把所有含.jsp的URL改成.php,费时费力)。URL Rewriting正好避免了这点,因为好的URL是能做到“不变应完变”的。
3. 防止某些黑客恶意攻击。有些大网站采用不同的技术开发不同功能的页面。而把拓展名改掉,让黑客无法确认此页面用的技术是什么,从而就无从下手。
4. 方便访问者使用。访问者不是程序员,他们不明白什么是.jsp,.php.aspx,他们只知道URL。所以统一把拓展名拿掉,或者同意把拓展名换为html,htm,有利于用户的使用。用户可以知道现在在你网站的位置,如何通过输入URL到某一页面。
实例:
Intelligencia.UrlRewriter.dll aspx重写为html实例
1、http://urlrewriter.net/ 下载解压缩后把Intelligencia.UrlRewriter.dll 文件添加引用到web工程里。
2.web.config配置:
<configSections>
<!--UrlRewriter-->
<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<!--UrlRewriter-->
<httpModules>
<add type="Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter" name="UrlRewriter" />
</httpModules>
</system.web>
</system.web>
<!--UrlRewriter-->
<rewriter>
<rewrite url="~/test_([a-zA-Z]+).html$" to="~/Show.aspx?Code=$1" processing="stop" />
</rewriter>
其中: <rewrite url="~/test_([a-zA-Z]+).html$" to="~/Show.aspx?Code=$1" processing="stop" />
若果code= abc的话,最终显示的结果为"虚拟目录名称/test_abc.html" 。如果吧.html替换成 .aspx那就是"虚拟目录名称/test_abc.aspx"
3.IIS配置:
如果是用"虚拟目录名称/test_abc.aspx" 的话,不需要配置IIS. 使用了"虚拟目录名称/test_abc.html" 配置IIS的方法如下: http://urlrewriter.net/index.php/support/installation/windows-server-2003/ 里面的图9不准确,准确的为:
还有第八步中的”untick Verify that file exists.“要看仔细。否则重写HTML就无效。
4:备注
不要在"应用程序扩展"里“添加" .html的映射,否则正常的html将无法访问。
5.在vs2005中,传多个参数应该加&在vs2003中,只用分号就好了
eg.
<RewriterConfig>
<Rules>
<RewriterRule>
<!--CreditNews BackGround update-->
<LookFor>~NewsClsManage-(\d*)-(\d*).html</LookFor>
<SendTo>~NewsClsManage.aspx?ClassID=$1&flag=$2</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
相关文章推荐
- 把动态网页.aspx转化为html(伪静态) aspx转html+配置
- aspx转化为html(伪静态)
- aspx转化为html(伪静态)
- aspx转化为html(伪静态)
- 将aspx重写成.html后缀的伪静态地址后,如果后台需要调用Session,可能会出现如下错误:
- 把HTML表单提交的数据转化成XML文件
- aspx生成HTML几个方法
- html内联元素与块状元素大全。以及什么时候用到相互转化
- html改为aspx文件后样式不对的解决方法!
- PHP中字符串与html相互转化函数
- 将动态aspx页面转换成为静态html页面的几种方法
- ASP.NET将Word文档转化为HTML格式的文档
- 伪静态是什么?伪静态与普通html静态网页区别?
- HTML控件ID和NAME属性的区别,以及如何在asp.net页面的.CS文件中获得.ASPX页面中HTML控件的值
- Java利用OpenOffice进行将word,excel转化成html解析到界面(上)
- asp.net伪静态后 html无法访问
- IIS开启伪静态后html静态页面无法访问的解决方法
- 把aspx页面伪装成静态html格式的实现代码
- 将指定目录下面得所有文件名从中文转化为拼音,并保存为html
- C#关于html颜色值的转化 ColorTranslator