cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diana Shannon <>
Subject [doc] FAQ, mod-rewrite, comments needed
Date Mon, 01 Jul 2002 11:40:18 GMT
Luca Morandinin recently updated the FAQ for Configuring Cocoon's 

The content for the second part of his FAQ on mod-rewrite
   ( How can I reach my Cocoon app from an URI other than <your-
server>/cocoon/<my-app>? )
follows. My question is at the end of the <faq-content> block.

This entry was tested under: Windows NT 4.0 + Apache 1.3.14 + Tomcat 
3.2 +
Cocoon 2.0b1. It is Apache-specific.

The idea is just to redirect a portion of the desired URI (bar) to the 
one within
the cocoon context (cocoon/bar).

Apache has an handy feature called mod_rewrite that does just this: URI
rewriting. (See the "URL Rewriting Guide" in the Apache user's guide for

First of all, you should instruct Apache to load the mod_rewrite.
Add (on a Windows system) to httpd.conf the following line:
   LoadModule rewrite_module modules/ApacheModuleRewrite.dll

(By the way it's quite likely that this line is already on the 
httpd.conf. You
just have to uncomment it).

Add this line to httpd.conf in order to activate mod_rewrite:
   RewriteEngine On

It is highly recommended to use the logging option of mod_rewrite, in
order to check the correctness of the URI rewriting. Just add these lines
to the httpd.conf:
  RewriteLog "C:/logs/rewrite.log"
   RewriteLogLevel 9

The first line tells Apache to put the URI rewriting log in the
c:\logs\rewrite.log file (which happens to be on a Windows system, of
course). The second one tells Apache to record everything mod_rewrite
does. If you don't want to log anything, just set RewriteLogLevel to

Now, it's time to do the URI rewriting trick.
  RewriteRule bar/(.*) /cocoon/bar/$1 [PT]

This line instructs Apache to redirect everything under "bar" to
"cocoon/foo" and to pass it on for other processing ("[PT]" option),
like mod_alias.

Just restart Apache and point your browser to:

It should work just fine.

The RewriteRule may not work in all cases (notably under Slackware Linux 
with Apache 1.3),
if so, try replacing it with:
RewriteRule ^/Foo /cocoon/Foo/ [R]
RewriteRule ^/Foo(.*) /cocoon/Foo$1 [R]

Liam Morley had the following comment:

In my experience, session support is lost when you use mod_rewrite 
because the cookie path for the Cocoon session is "/cocoon". Because the 
browser sees the path differently, the session cookie is not granted 
access, and sessions don't work. I got around this by renaming Cocoon to 
ROOT, I imagine setting the default docBase would have the same effect.

Would anyone else care to comment on Liam's comment? If not, I'll go 
ahead and incorporate Liam's comment into the FAQ. Thanks, Liam, for 
sending your feedback to Luca and me.



Please check that your question  has not already been answered in the
FAQ before posting.     <>

To unsubscribe, e-mail:     <>
For additional commands, e-mail:   <>

View raw message