[opencms-dev] opencms URL rewrite

Rene Hinojosa r_hinojosa at cityofsouthfield.com
Tue Sep 30 20:45:01 CEST 2003


Greetings All,

Situation: Remove /opencms/opencms/ from URL. User enters site from top 
level.

Conditions: Users must see a short URL when clicking on links. Site 
administrators enter URL links as normal.

Solution: I've been reading some of the solutions to removing the 
/opencms/opencms/ out of the URL. I've tried several of them without 
success and been doing some reading on Apache mod_rewrite. From what I 
come up with, it works pretty good. I've added the following to my 
httpd.conf file:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 1

#Redirect root URL entry through proxy. URL
RewriteRule ^/$ /opencms/opencms/internet/ [P]

#Redirect all entries to /internet/  I have a directory that I want as 
the root of the site
RewriteRule ^/opencms/opencms/internet/?(.*)$ /internet/$1 [R]

#Redirect admin login properly. Can use RewriteCond to make login 
secure by use host variable or whatever.
RewriteRule ^/system/login$ /opencms/opencms/system/login [R]

#Redirect all /internet/ page through tomcat
RewriteRule ^/internet/(.*)$ http://<<insert your tomcat 
ip>>:8080/opencms/opencms/internet/$1 [P,QSA]

</IfModule>


This should work if you are running apache with mod_jk, mod_proxy, 
mod_rewrite and your tomcat server is on the same box as your apache.

Hope this helps someone, Let me and the group know if there are any 
problems or tweaks needed.

Rene




More information about the opencms-dev mailing list