zoukankan      html  css  js  c++  java
  • asp.net生成伪静态2 子曰

    大家对伪静态(URL重写)有什么看法?
    以.aspx\.asp\.php结尾的页伪静态为以.htm或者.html结尾的页有什么看法,性能会得到提高吗,有什么好处?
    那么或者直接生成静态页面又有什么好处,是否推荐在一个网站大量使用呢?
    对于腾讯那样的大的门户网站他们的新闻页是生成的静态页呢或者是伪装的?

    最佳答案:
    运行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中,传多个参数应该加&amp;在vs2003中,只用分号就好了
    eg.
    <RewriterConfig>
        <Rules>
          <RewriterRule>
            <!--CreditNews BackGround update-->
            <LookFor>~NewsClsManage-(\d*)-(\d*).html</LookFor>
            <SendTo>~NewsClsManage.aspx?ClassID=$1&amp;flag=$2</SendTo>
          </RewriterRule>
        </Rules>
    </RewriterConfig>

  • 相关阅读:
    转:神经网络入门
    转:Webkit Flex伸缩盒模型属性备忘
    css3 display:-webkit-box
    display:inline和display:block及html常用标签
    display
    weui flex 分布
    图片、字体、iconfont矢量图
    flex weui列表demo
    方法调用
    C#多线程之Task
  • 原文地址:https://www.cnblogs.com/suixufeng/p/3336129.html
Copyright © 2011-2022 走看看