urlrewrite实战实例

<?xml version="1.0" encoding="utf-8"?>   
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite decode-using="UTF-8">
    <rule>
        <from>/$</from>
        <to type="forward">/shop/showIndexAll</to>
    </rule> 
    
    <!-- 手机浏览器包含jsession删掉  ,下面的wildcard:通配符,(regex正则表达式 )-->
    <outbound-rule encodefirst="true">
    <from>^(.*);jsessionid=.*$</from>
    <to>$1</to>
    </outbound-rule>
    <outbound-rule match-type="wildcard">
    <from>*;jsessionid=*</from>
    <to>$1</to>
    </outbound-rule>
    
    <rule>
        <from>index.html</from>
        <to type="forward">showIndexAll.action</to>
    </rule> 
    <outbound-rule match-type="regex">
        <from>showIndexAll.action</from>
        <to>index.html</to>
    </outbound-rule>
    
    <!-- 一个ACTION没有方法 -->
    <rule>
        <from>^/(\w+).html$</from>
        <to type="forward">/$1.action</to>
    </rule> 
    <outbound-rule match-type="regex">
        <from>/(\w+).action$</from>
        <to>/$1.html</to>
    </outbound-rule>
     
    <!-- 一个ACTION有方法 -->
    <rule>
        <from>^/(\w+)!(\w+).html$</from>
        <to type="forward">/shop/$1!$2.action</to>
    </rule>
    <outbound-rule match-type="regex">
        <from>(\w+)!(\w+).action$</from>
        <to>$1!$2.html</to>
    </outbound-rule>
    
    <!-- TOP页面类型过滤 -->
    <rule>
        <from>(\w+).shtml$</from>
        <to type="forward">/shop/commInfoManage!findListByTypeId.action?commTypeId=$1</to>
    </rule>
    <outbound-rule match-type="regex">
        <from>commInfoManage!findListByTypeId.action\?commTypeId=(\w+)$</from>
        <to>$1.shtml</to>
    </outbound-rule>
     
     <!-- 用户中心 -->
     <rule>
        <from>ucm.uhtml</from>
        <to type="forward">/shop/userCent.action</to>
    </rule> 
    <outbound-rule match-type="regex">
        <from>userCent.action$</from>
        <to>ucm.uhtml</to>
    </outbound-rule>
     
     
     <!-- <rule>
         <from>^/news/([0-9]+).html$</from>
         <to>/news/news.jsp?newsId=$1</to>
     </rule>    
     
    <outbound-rule>
        <from>^/shop/news/news.jsp\?newsId=([0-9]+)$</from>
        <to>/shop/news/$1.html</to>
    </outbound-rule> -->
</urlrewrite>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值