urlrewritefilter用于tomcat 7.0.64的tuckey配置

时间:2016-06-25 09:02:37

标签: tuckey-urlrewrite-filter

我正在尝试配置urlrewritefilter 4.0.3,但我不确定理解指令并以正确的方式设置它。 我正在使用安装在/opt/apache-tomcat-7.0.64/下的apache-tomcat-7.0.64,并使用以下配置:

使用CATALINA_BASE:/opt/apache-tomcat-7.0.64 使用CATALINA_HOME:/opt/apache-tomcat-7.0.64 使用CATALINA_TMPDIR:/opt/apache-tomcat-7.0.64/temp 使用JRE_HOME:/opt/jdk1.7.0_80/jre 使用CLASSPATH:/opt/apache-tomcat-7.0.64/bin/bootstrap.jar:/opt/apache-tomcat-7.0.64/bin/tomcat-juli.jar

我已将配置设置如下:

urlrewritefilter-4.0.3.jar  under folder /opt/apache-tomcat-7.0.64/lib
web.xml and urlrewrite.xml files under /opt/apache-tomcat-7.0.64/webapps/ROOT/WEB-INF
configuration for these files are:
    web.xml content ini  
        <?xml version="1.0" encoding="ISO-8859-1"?>
    <!--
     Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    -->

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0"
      metadata-complete="true">

        <filter>
            <filter-name>UrlRewriteFilter</filter-name>
            <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>

            <!-- set the amount of seconds the conf file will be checked for reload
            can be a valid integer (0 denotes check every time,
            empty/not set denotes no reload check) -->
            <init-param>
            <param-name>confReloadCheckInterval</param-name>
            <param-value>0</param-value>
            </init-param>
        </filter>

        <filter-mapping>
            <filter-name>UrlRewriteFilter</filter-name>
            <url-pattern>/*</url-pattern>
            <dispatcher>REQUEST</dispatcher>
            <dispatcher>FORWARD</dispatcher>
        </filter-mapping> 

    </web-app>
    web.xml content end     
    ******************************
    urlrewrite.xml content ini 
    <?xml version="1.0" encoding="utf-8"?>

    <!DOCTYPE urlrewrite
    PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
    "http://www.tuckey.org/res/dtds/urlrewrite3.0.dtd">

    <!--
    UrlRewriteFilter from http://tuckey.org/urlrewrite/ proyect
    -->
    <urlrewrite>
        <rule>
            <name>redirect</name>
            <condition name="host" operator="notequal">^www.tucarne.com</condition>
            <from>^/(.*)</from>
            <to type="permanent-redirect" last="true">http://www.tucarne.com/$1</to>
        </rule>
    </urlrewrite>

    urlrewrite.xml content end

正如我从手册和常见问题解答中获取的网页和urlrewrite文件都设置在正确的路径中并且具有正确的包含但它不起作用。我不知道为什么是错的。

你能帮助我吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

请注意ROOT Web应用程序不能提供其他Web应用程序&#39;要求。例如。如果部署webapplication WEBAPP1,那么ROOT Web应用程序将不会提供URL [protocol]://[hostname]:[port]/WEBAPP1/somepage.html

它将由Web应用程序WEBAPP1提供。

如果在ROOT Web应用程序中配置Turkey过滤器,则它将仅处理对ROOT Web应用程序的请求(上下文路径为零长度字符串; [protocol]://[hostname]:[port]/[protocol]://[hostname]:[port]/?somearg=value)。