Removing the /opencms/opencms prefix without using Apache

From OpenCms Wiki
Revision as of 23:58, 26 November 2010 by 83.217.131.83 (Talk)
Jump to: navigation, search

Contents

Removing the /opencms/opencms prefix without using Apache

Note: Information here: http://www.tangmonk.com/km/removeOpencmsPrefix.html

Principle

In this setup, Tomcat should be set up to listen on port 80. You do not need any Apache httpd for this setup anymore. All is done in Tomcat.

The first /opencms is removed by installing OpenCms as ROOT context (thus, before deploying, rename opencms.war to ROOT.war)

The second /opencms is removed by using UrlRewrite, which works similar to mod_rewrite as known from Apache httpd.

First, download the UrlRewriteFilter archive V2.6. Then, extract the archive and put the urlrewrite-2.6.0.jar into the /lib of your container or into WEB-INF/lib of your OpenCms installation.

Config Files

WEB-INF/urlrewrite.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN" "http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<urlrewrite>
  <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>

WEB-INF/web.xml

Add this to OpenCms' 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>

WEB-INF/config/opencms-system.xml

No change needed to this file. Just set up your hosts and workplace as usual. Note that, as usual, the workplace-server must have a dedicated url.

WEB-INF/config/opencms-importexport.xml

<rendersettings>
 <rfs-prefix>${CONTEXT_NAME}/export</rfs-prefix>
 <vfs-prefix>${CONTEXT_NAME}</vfs-prefix>
 <userelativelinks>false</userelativelinks>
 <exporturl>http://127.0.0.1:80${CONTEXT_NAME}/handle404</exporturl>
 ...
</rendersettings>
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox