You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Liam Morley <lm...@WPI.EDU> on 2001/10/08 22:22:39 UTC

how to get "dir-name/" to point to "dir-name/index.html"

I have the following rather inefficient code in my sitemap-I'm sure it can be
simplified, but I don't know how. First of all, how do you get "dir-name/" to
redirect or point to "dir-name/index.html" (using either Cocoon or Tomcat),
and how do you get "dir-name" to redirect to "dir-name/". The following is how
I'm doing it right now:
   <map:match pattern="dir-name">
     <map:redirect-to uri=" dir-name/"/>
   </map:match>
   <map:match pattern="dir-name/">
     <map:generate/>
     <map:transform/>
     <map:serialize/>
   </map:match>
   <map:match pattern="dir-name/*.html">
     <map:generate/>
     <map:transform/>
     <map:serialize/>
   </map:match>
   <map:match pattern="dir-name/sub-dir">
     <map:redirect-to uri="dir-name/sub-dir/"/>
   </map:match>
   <map:match pattern="dir-name/sub-dir/">
     <map:generate"/>
     <map:transform/>
     <map:serialize/>
   </map:match>
   <map:match pattern="dir-name/sub-dir/*.html">
     <map:generate/>
     <map:transform/>
     <map:serialize/>
   </map:match>

There has to be a better way... how do I fix that? Thanks...
Liam Morley

mod-rewrite troubles (formerly RE: how to get "dir-name/" to point to "dir-name/index.html")

Posted by Liam Morley <lm...@WPI.EDU>.
Nikola,

Thank you very much for your help thus far- that was a great assistance.
I'm currently having some troubles with mod_rewrite. It seems that when
I try the following:

RewriteRule mydir/(.*) cocoon/mydir/$1 [PT]

I get a "HTTP 400 - Bad Request" response after trying to access
http://localhost/mydir/. If I try http://localhost/mydi/ instead, I get
the proper HTTP 404. Could anybody shed some light on this?

Also, Nikola, you said that "If they are not real directories - then you
should just write a regexp that looks for that pattern ^(.+[^/])$ except
explicitly say what the directory is." Do you mean something like this:

RewriteRule    mydir$           mydir/ [R]
RewriteRule    mydir/subdir1$   mydir/subdir1/ [R]
RewriteRule    mydir/subdir2$   mydir/subdir2/ [R]

Or perhaps something like:
RewriteRule    ^(.+[^(?:\.html)])$    $1/ [R]

What I was trying to say there (and I hope it came out right) is that
anything that doesn't end with ".html" will be redirected to include a
slash after it. Would that work, do you think? Again this is all
hypothetical at the moment as I'm still getting "HTTP 400 - Bad Request"
messages. The Rewrite log does seem to indicate the request is being
handled correctly and that the correct message is being passed
afterwards (at least, I think so)...

Thanks again, you've been an incredible help.

Liam Morley


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

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: how to get "dir-name/" to point to "dir-name/index.html"

Posted by Nikola Vouk <nv...@eos.ncsu.edu>.
If you are using apache, then you can use mod-rewrite to redirect to 
the apache. The trick is in the apache config file. Use something 
like the following:
Remember that the pattern match can be anything - not even a real 
directory so you will have to play some tricks. My example follows:

As described on http://httpd.apache.org/docs/misc/rewriteguide.html
You can have the server automatically check to see if the directory 
exists, then  add trailing slash which will get caught by the 
mod_jserv or the current

# this tells apache to redirect (httpd.conf)
RewriteEngine  on
RewriteRule    ^/dir-name$ /dir-name/index.html [R]

# this tells apache to send the request to ajp13 (httpd.conf)
JkMount /dir-name/ ajp13

# sitemap.xconf - now you only need to the original - faster
# and better
<map:match patter="dir-name/">
   <map>...
</map:match>

If you follow a pattern (and if all of these are all directories), then you
could create a generic rewrite in the apache engine like this

RewriteEngine  on
RewriteCond    %{REQUEST_FILENAME}  -d
RewriteRule    ^(.+[^/])$           $1/ [R]

If they are not real directories - then you should just write a 
regexp that looks for that pattern ^(.+[^/])$ except explicitly say 
what the directory is.


You just need the addition to the sitemap.conf and your jkmounts. The 
answer to your problems (of performance) can all be solved with 
apache faster than using tomcat.
hope this helps some,
nik

At 4:22 PM -0400 10/8/01, Liam Morley wrote:
>I have the following rather inefficient code in my sitemap-I'm sure it can be
>simplified, but I don't know how. First of all, how do you get "dir-name/" to
>redirect or point to "dir-name/index.html" (using either Cocoon or Tomcat),
>and how do you get "dir-name" to redirect to "dir-name/". The following is how
>I'm doing it right now:
>    <map:match pattern="dir-name">
>      <map:redirect-to uri=" dir-name/"/>
>    </map:match>
>    <map:match pattern="dir-name/">
>      <map:generate/>
>      <map:transform/>
>      <map:serialize/>
>    </map:match>
>    <map:match pattern="dir-name/*.html">
>      <map:generate/>
>      <map:transform/>
>      <map:serialize/>
>    </map:match>
>    <map:match pattern="dir-name/sub-dir">
>      <map:redirect-to uri="dir-name/sub-dir/"/>
>    </map:match>
>    <map:match pattern="dir-name/sub-dir/">
>      <map:generate"/>
>      <map:transform/>
>      <map:serialize/>
>    </map:match>
>    <map:match pattern="dir-name/sub-dir/*.html">
>      <map:generate/>
>      <map:transform/>
>      <map:serialize/>
>    </map:match>
>
>There has to be a better way... how do I fix that? Thanks...
>Liam Morley
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org>


-- 

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

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>