Beliebte Suchanfragen

Cloud Native

DevOps

IT-Security

Agile Methoden

Java

//

OpenCms 8: avoiding “opencms/opencms” in URL

6.8.2013 | 1 minutes of reading time

A normal local installation of OpenCms in a Tomcat container yields URLs like http://localhost:8080/opencms/opencms/welcome/  etc. If OpenCms is the only application on Tomcat, there’s no need for the first ‘opencms’. And if the second will be automatically filtered out, you can use OpenCms with URLs like this: http://localhost:8080/welcome/  .

There’s no need to use an additional Apache WebServer (httpd), just plain Tomcat and a Java class and some tricks.

  1. Before installation of OpenCms rename original opencms.war file to ROOT.war
  2. remove default ROOT folder in your $CATALINA_HOME/webapps (e.g. /usr/local/apache-tomcat-7.0.41/webapps)
  3. install MySQL server if needed
  4. start Tomcat (e.g. with /usr/local/apache-tomcat-7.0.41/bin/startup.sh )
  5. start OpenCms installation in your browser (localhost:8080/setup )
  6. next… next… finish (default values should be ok for your local installation)
  7. see welcome page (with one remaining ‘opencms’ in URL): http://localhost:8080/opencms/welcome/
  8. in web.xml (in ROOT/WEB-INF folder) add the following code:
    <filter>
       <filter-name>UriRewriteFilter</filter-name>
       <filter-class>com.dcampus.opencms.web.UriRewriteFilter</filter-class>
       <init-param>
           <param-name>ignore-uri</param-name>
           <param-value>/opencms/,/resources/,/export/,/setup/,/update/,/webdav/,/opencms-errorhandler/</param-value>
       </init-param>
       <init-param>
       <param-name>prefix</param-name>
       <param-value>/opencms</param-value>
       </init-param>
    </filter>
    <filter-mapping>
       <filter-name>UriRewriteFilter</filter-name>
       <url-pattern>/*</url-pattern>
    </filter-mapping>
    
  9. and alter in that same web.xml file the following line from
    <context-param>
       <param-name>OpenCmsServlet</param-name>
       <param-value>/opencms/*</param-value>
    </context-param>
    

    to

    <context-param>
       <param-name>OpenCmsServlet</param-name>
       <param-value>/*</param-value>
    </context-param>
    

    (‘/opencms’ removed)

  10. now download the UriRewriteFilter Java class into your home directory, compile it and deploy it to OpenCms as follows:
    1. wget http://opencms.996256.n3.nabble.com/attachment/10246/0/UriRewriteFilter.java
      
    2. javac -cp /usr/local/apache-tomcat-7.0.41/lib/servlet-api.jar UriRewriteFilter.java
      
    3. mkdir -p /usr/local/apache-tomcat-7.0.41/webapps/ROOT/WEB-INF/classes/com/dcampus/opencms/web
      
    4. cp UriRewriteFilter*.class /usr/local/apache-tomcat-7.0.41/webapps/ROOT/WEB-INF/classes/com/dcampus/opencms/web
      
  11. restart Tomcat
  12. go to URL-shortened welcome page: http://localhost:8080/welcome

    Appendix:
    http://lists.opencms.org/pipermail/opencms-dev/2011q3/035947.html

    http://www.jvmhost.com/opencms-hosting#url_shortening

 

share post

Likes

0

//

More articles in this subject area

Discover exciting further topics and let the codecentric world inspire you.

//

Gemeinsam bessere Projekte umsetzen.

Wir helfen deinem Unternehmen.

Du stehst vor einer großen IT-Herausforderung? Wir sorgen für eine maßgeschneiderte Unterstützung. Informiere dich jetzt.

Hilf uns, noch besser zu werden.

Wir sind immer auf der Suche nach neuen Talenten. Auch für dich ist die passende Stelle dabei.