标签:hand text 创建 新建 eve conf 添加 cms doctype
采用刚刚的方法安装OpenCMS之后,站点url中会存在两个opencms,造成访问url路径过长,下面讲解一种去掉两个opencms的方法。
1.去掉第一个opencms
安装时采用ROOT安装,即把opencms.war改名为ROOT.war放到webapp下进行安装,这样第一个/opencms就去掉了,不用配置其他任何参数。
此时的安装路径:http://localhost:8080/ setup
2.去掉第二个opencms
使用urlrewrite模块实现,步骤如下:
(1)下载urlrewrite-3.2.0.jar包,把jar包放到tomcat根目录/webapps/ROOT/WEB-INF/lib目录下;
(2)在tomcat根目录/webapps/ROOT/WEB-INF/目录下新建一个urlrewrite.xml文件,代码清单参见1;
代码清单1 tomcat根目录/webapps/ROOT/WEB-INF/urlrewrite.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
"http://tuckey.org/res/dtds/urlrewrite3.2.dtd">
<!--
Configuration file for UrlRewriteFilter
http://tuckey.org/urlrewrite/
-->
<urlrewrite>
<rule>
<from>^/tc-mgr/(.*)$</from>
<to>/tc-mgr/$1</to>
</rule>
<rule>
<condition type="request-uri" operator="notequal">^/export/.*$</condition>
<condition type="request-uri" operator="notequal">^/resources/.*$</condition>
<condition type="request-uri" operator="notequal">^/opencms-errorhandler/.*$</condition>
<condition type="request-uri" operator="notequal">^/webdav/.*$</condition>
<condition type="request-uri" operator="notequal">^/opencms/.*$</condition>
<condition type="request-uri" operator="notequal">^/setup/.*$</condition>
<from>^/(.*)$</from>
<to>/opencms/$1</to>
</rule>
</urlrewrite>
(3)创建完urlrewrite.xml文件后,打开tomcat根目录/webapps/ROOT/WEB-INF/web.xml文件,找到以下代码片段:
<listener>
<listener-class>org.opencms.main.OpenCmsListener</listener-class>
</listener>
然后在其后面添加过滤器配置代码,参见代码清单2;
代码清单2 tomcat根目录/webapps/ROOT/WEB-INF/web.xml:新增过滤器配置
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>-1</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>ERROR</param-value>
</init-param>
<init-param>
<param-name>statusEnabled</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>statusPath</param-name>
<param-value>/status</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
(4)接下来修改tomcat根目录/webapps/ROOT/WEB-INF/config/opencms-importexport.xml,找到如下的配置代码片段:<vfs-prefix>${CONTEXT_NAME}/${SERVLET_NAME}</vfs-prefix>,删除其中的/${SERVLET_NAME},即最终修改为:
<vfs-prefix>${CONTEXT_NAME}</vfs-prefix>
至此,第二个/opencms去除成功,记得修改完毕后重启Tomcat服务器,首页地址如下:
http://localhost:8080/ index.html
OpenCMS后台工作区的登录页面链接地址如下:
http://localhost:8080/ system/login/
标签:hand text 创建 新建 eve conf 添加 cms doctype
原文地址:http://www.cnblogs.com/qubo520/p/7040057.html