`
fengyong0912
  • 浏览: 103869 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

tomcat服务器使用url rewrite1

    博客分类:
  • JAVA
阅读更多
让tomcat服务器使用url rewrite1.    第一步:首先到这里下载:
http://tuckey.org/urlrewrite/urlrewritefilter-3.0.4
2. 解压urlrewritefilter-3.0.4.zip
里面包含几个文件

WEB-INF
–lib\urlrewrite-3.0.4.jar
     –urlrewrite.xml

按照目录位置放在工程的WEB-INF文件夹中
3. WEB-INF/web.xml配置UrlRewriteFilter
<servlet-mapping> 前面加入

      <filter>
            <filter-name>UrlRewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
     </filter>
     <filter-mapping>
            <filter-name>UrlRewriteFilter</filter-name>
            <url-pattern>/*</url-pattern>
     </filter-mapping>
4. WEB-INF/urlrewrite.xml 中写入rewrite规则
加入诸如此类的正则表达规则:
Redirect one url
         <rule>
             <from>/some/old/page.html</from>
             <to type="redirect">/very/new/page.html</to>
         </rule>

Redirect a directory
         <rule>
             <from>/some/olddir/(.*)</from>
             <to type="redirect">/very/newdir/$1</to>
         </rule>

Clean a url
         <rule>
             <from>/products/([0-9]+)</from>
             <to>/products/index.jsp?product_id=$1</to>
         </rule>
     eg, /products/1234 will be passed on to /products/index.jsp?product_id=1234 without the user noticing.

Browser detection
         <rule>
             <condition name="user-agent">Mozilla/[1-4]</condition>
             <from>/some/page.html</from>
             <to>/some/page-for-old-browsers.html</to>
         </rule>
eg, will pass the request for /some/page.html on to /some/page-for-old-browsers.html only for older browsers whose user agent srtings match Mozilla/1, Mozilla/2, Mozilla/3 or Mozilla/4.

5.重启tomcat,完成




例如:
在在WEB-INF/urlrewrite.xml 中写入rewrite规则为:
<rule>
      <from>gallery/t1.html</from>
      <to>epg/template/gallery%2CGalleryHome.vmx</to>
</rule>

<rule>
      <from>watch/([0-9]+).html</from>
      <to>epg/template/play%2CWatch.vmx?actid=$1</to>
</rule>

键入:http://www.bocoo.com/CN/gallery/t1.html就进入
       http://www.bocoo.com/CN/ epg/template/gallery%2CGalleryHome.vmx

       http:// www.bocoo.com /CN/watch/108.html就进入
       http:// www.bocoo.com /CN/epg/template/play%2CWatch.vmx?actid=108
分享到:
评论

相关推荐

    Apache+Tomcat实现UrlRewrite

    NULL 博文链接:https://cygogo.iteye.com/blog/903344

    netcn_URLRewrite

    为什么使用UrlRewrite: 1 处理这样的情形:你要更改你的web应用中网页的结构 但你同时也要确保在你移动网页后 那些被人收藏的老URL不会成为死链接 2 其次可以隐藏网站所用的编程语言 还可以提高网站的可移植性 ...

    URL Rewrite.zip

    URL Rewrite是微软针对IIS推出的一种对URL进行重写的扩展模块,目前支持用于IIS7及以上版本。该模块使IIS管理员能够创建强大的自定义规则,语法支持正则规则以及通配符规则过滤。它能够根据HTTP头和IIS服务器变量...

    urlrewrite 支持自定义多配置文件

    1.如果想用原生的urlRewriteFilter confPath 请放完整地址(eg:WEB-INF/urlrewrite.xml); 2.如果想读多个配置文件,用法: ①confPath只放相对目录 ②fileNameRegex 为读取文件匹配(eg:/WEB-INF 目录下有文件url...

    urlrewrite-maven-example.zip

    urlrewrite重写地址,Urlrewrite 2.5.2 现在有2.6版本的,自己去网上找吧

    urlrewrite 支持自定义多配置文件(*通配符)

    urlrewrite 只支持单个配置文件,默认的配置文件为:/WEB-INF/urlrewrite.xml 现在对urlrewrite-3.2的源码进行了修改,使它能够支持多文件和通配符的形式加载自定义配置文件,即可以进行如下的配置: &lt;param-name&gt;...

    IIS URL Rewrite模块(URL 重写).xmind

    IIS URL Rewrite模块(URL 重写)

    UrlReWrite(Url重写或伪静态)

    UrlReWrite(Url重写或伪静态)UrlReWrite(Url重写或伪静态)

    打造UrlRewrite源码

    打造UrlRewrite源码 UrlRewrite一般都是在web.config里配置访问规则在路由到实际页面,所以先实现自定义节点信息读取,这里我定义了俩个类 webconfig定义了组,不需要的话可以把UrlRewriteConfigGroup类去掉并修改...

    UrlReWrite(Url重写或伪静态)完美示例源码

    URL重写技术在今天已不是什么新鲜的话题了,在Apache服务器提供了名为mod_rewrite的URL重写模块,而在IIS服务器上,也有很多商业的ISAPI 筛选器模块可供使用。然而这对于我们,没有很多的资金或使用的共享服务器,...

    IIS Urlrewrite2

    IIS Urlrewrite2,IIS服务器URl重写工具,,IIS服务器URl重写工具,,IIS服务器URl重写工具,

    urlrewrite-3.1.0.jar

    urlrewrite Jar包 urlrewrite-3.1.0.jar

    URLRewrite配置和使用

    使用urlrewrite的优点: 1、满足搜索引擎的要求 2、隐藏技术实现,提高网站的移植性 3、满足美感的要求

    URLRewrite URL重写组件

    URLRewrite URL重写组件 里边有相关配置说明 包括了web.Config 外附一个Css

    URLRewrite帮助文档

    URLRewrite使用时候一些属性的配置说明

    UrlRewrite.rar

    UrlRewrite.rarUrlRewrite.rar

    UrlRewrite.dll

    UrlRewrite.dll 在使用开发的时候,win7或者win8的系统,可能会需要

    URLrewrite-实例

    java urlrewrite demo

    urlrewrite 4.0.3 jar包.rar

    urlrewrite 4.0.3 jar

    iis urlrewrite文件

    iis urlrewrite文件

Global site tag (gtag.js) - Google Analytics