Luca Morandinin recently updated the FAQ for Configuring Cocoon's 
Environment.

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.

<faq-content>
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
details).

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
0.

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:
   <your-server>:8080/bar/<something>

It should work just fine.

Note:
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]
</faq-content>

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.

Thanks.

Diana




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to