[daisy] Virtual hosting and URL management

Olivier Lange wire at petit-atelier.ch
Thu Aug 4 04:25:06 CDT 2005


Andrew Savory wrote:

> Hi,
>
> I'm trying to get a virtual host set up with a Daisy instance, and 
> I've run into a couple of issues.
>
> The first one is with my Apache config. I've read through the mail 
> archives and seen the various threads on proxying, and looked at the 
> docs at http://cocoondev.org/daisydocs-1_3/admin/99.html but I'm a 
> bit stuck.
>
> Here's what I want to do: have a site (http://www.somesite.co.uk/) 
> point to a daisy instance (http://localhost:port/daisy/somesite/). 
> Unfortunately, my Apache mod_rewrite mojo has deserted me, so I 
> thought I'd see if anyone has solved this.
>
> I'm currently using:
>
>        DocumentRoot /path/to/daisy-1.3-M3/daisywiki/webapp/
>        RewriteEngine on
>        RewriteRule "^/resources/?(.*)" "/daisy/somesite/$0" [L]
>        RewriteRule "^/daisy/resources/?(.*)" "$0" [L]
>        RewriteRule "^/WEB-INF/?(.*)" "$0" [L,F,NC]
>        RewriteRule "^/(.*)" "http://localhost:8888/daisy/somesite/ $1"
> [P]
>        RewriteRule "^/$" http://localhost:8888/daisy/somesite/" [P]
>        ProxyRequests Off
>        ProxyPassReverse / http://localhost:8888/daisy/somesite/
>        ProxyPreserveHost On
>
> With this, all the URLs generated by Daisy point to http://
> www.somesite.co.uk/daisy/foo instead of http://www.somesite.co.uk/
> foo, which means they all break. Do I really need to delve into the 
> Cocoon app to fix this, or am I doing something silly?

I ran in the same problem. The links generated by Daisy XSL scripts are
all in the form {$mountPoint}pathToSomeResource. What you would need is
$mountPoint = ''. AFAIK, yes, you would need to delve into the Cocoon
app to fix it

Daisy sets the 'mountPoint' request attribute in its main pipeline,
which is passed as a parameter all XSL scripts needing it, with a call
to the 'DetermineMountPoint' action.

In your case (and mine), the problem is that the external URI
(http://www.somesite.co.uk/foo) isn't the same as the request URI given
to the sitemap (http://localhost:8888/daisy/somesite/foo), from which
the mountPoint is derived.

One way to solve this is to mount the Daisy sitemap at the root from the
main Cocoon sitemap.

    <map:match pattern="**">
      <map:mount check-reload="yes" src="daisy/" uri-prefix=""/>
    </map:match>

Another way is to tweak the Daisy sitemap and set the mountPoint
attribute yourself, replacing the call to the DetermineMountPoint action.

    <!-- <map:act type="DetermineMountPoint"/> -->
    <map:act type="SetRequestAttribute">
        <map:parameter name="mountPoint" value=""/>
    </map:act>

I'm prefering the first, as it doesn't change the Daisy sitemap.

>
> The second issue is with URLs. I want to map URLs like http://server/
> 2.html to http://server/index.html, and reading http://cocoondev.org/
> daisydocs-1_3/daisywiki/general/116.html
> suggests it is possible. However, that web page doesn't actually 
> explain how to do it!

While editing the navigation document, the string you enter for the
optional Node ID attribute will replace the document ID, if specified.
So you would need to enter 'index' as the Node Id.

There is however one catch, I guess this is related to your problem
also: links to the root of the site, such as '/daisy/somesite/' are
rewritten to '/daisy/somesite/<homepageDocId>.html' by Daisy's sitemap.

The homepageDocId is taken from the site configuration
(siteconf.xml/homepageDocId) and the nodeId is ignored in that case.
This applies also for the root page of Daisy, with the list of available
sites.

I handled this with a RewriteRule. I think this would do for you:

    RewriteRule "^/$" http://localhost:8888/daisy/somesite/index.html" [P]

or even:

    RewriteRule "^(.*)/$"
http://localhost:8888/daisy/somesite/$1/index.html" [P]

In that case, you need to ensure you have a document with a nodeId of
'index' for all levels of the site hierarchy in the navigation document.

>
> Incidentally, searching the mail archive on the second issue I got:
>
> javax.xml.transform.TransformerException: The reference to entity 
> "locale" must end with the ';' delimiter.
>
> (with http://search.cocoondev.org/index.jsp?
> pageOffset=2&z=0.5862957440334122&nbrec=10&txt_search=URL&catsel=daisy )
>
>
> Andrew.

(no clue for this.)

Olivier


More information about the daisy mailing list