【问题标题】:Tuckey URL Rewrite - Remove .html ExtensionsTuckey URL 重写 - 删除 .html 扩展
【发布时间】:2012-02-24 04:35:59
【问题描述】:

我浏览了整个网络,但似乎无法弄清楚这一点。我正在使用 Tuckey 重写引擎。我已经阅读了手册并在没有帮助的情况下查看了示例。

我想从 URL 中删除“.html”扩展名,同时保留参数(如果有的话)。

这是我目前所拥有的(非工作):

<rule>
    <note>Example: http://hostname/sample/loginhelp?cid=2 is masked from http://hostname/sample/loginhelp.html?cid=2</note>
    <from>^(.*)\?(.*)$</from> 
    <to>$1.html?$2</to>
</rule>
<outbound-rule>
    <note>Example: http://hostname/sample/loginhelp.html?cid=2 is redirected to http://hostname/sample/loginhelp?cid=2</note>
    <from>^(.*)(\.html)(.*)$</from>
    <to type="redirect">$1$2</to>
</outbound-rule>

规则或出站规则似乎在任何情况下都不起作用。我知道 Tuckey 正在工作,因为我可以让其他规则起作用,但不是这个。另外,虽然我认为这并不重要,但我正在使用 Seam 堆栈。我错过了什么?

【问题讨论】:

    标签: regex url-rewriting wildcard http-redirect tuckey-urlrewrite-filter


    【解决方案1】:

    使用wildcard matching engine 来简化:

    <rule match-type="wildcard">
        <from>*.html?*</from>
        <to>$1?$2</to>
    </rule>    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-03-04
      • 2019-04-21
      • 1970-01-01
      • 2012-11-02
      • 2014-01-25
      • 1970-01-01
      • 2013-09-15
      • 2017-09-09
      相关资源
      最近更新 更多