【发布时间】:2016-06-25 09:02:36
【问题描述】:
我正在尝试配置 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 使用类路径:/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
正如我从手册和常见问题解答中获取的那样,web 和 urlrewrite 文件设置在正确的路径中,并且包含正确的内容,但它不起作用。我不知道为什么错了。
你能帮我吗?
提前致谢。
【问题讨论】: