# Apache configuration for openCMS.
# This allows the use of shorter URLs, removing the first /opencms/.
# The second one needs to stay there so that static exporting can work.

# The openCMS link substituter will still create /opencms/opencms/APP/ 
# or /opencms/export/APP/ links.  So the next step is to change that.  
# Left as an exercise for the reader, but these rules should work either 
# way.  BTW, if someone changes the link substituter, let us all know how.

# myopencms.com is a pretend tomcat server running openCMS.
# /APP/ is a pretend directory in the root of the pretend openCMS VFS, 
# it holds your openCMS project. 

# The rewrite module must be loaded.
# Proxy gets done before alias (No alias rules here though).
# Alias order is important, and only the first match works.
# Rewrite rules loop through until told to otherwise.

# There are lots of ways you can interface Apache with tomcat, we use the proxy
# method here just for the sake of a simple example.
<IfModule mod_proxy.c>
ProxyPass        /opencms/   http://myopencms.com:8082/opencms/
ProxyPassReverse /opencms/   http://myopencms.com:8082/opencms/
</IfModule>

# Now for the rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 1
<IfModule mod_proxy.c>
# Reroute through the proxy here.
RewriteRule ^/opencms/export/APP/(.*)$    http://myopencms.com:8082/opencms/export/APP/$1 [L,P]
RewriteRule ^/opencms/opencms/APP/(.*)$   http://myopencms.com:8082/opencms/opencms/APP/$1 [L,P]
RewriteRule ^/export/APP/(.*)$            http://myopencms.com:8082/opencms/export/APP/$1 [L,P]
RewriteRule ^/opencms/APP/(.*)$           http://myopencms.com:8082/opencms/opencms/APP/$1 [L,P]
</IfModule>
</IfModule>

