Website Downloads Documentation Knowledgebase Wiki Issue tracker Commercial support

URL management for daisy sites

Getting rid of the /daisy/ prefix

This explained in the daisy documentation already.

Using daisy for a single site only

An integral part of the daisy wiki is the concept of different sites which can be defined for a daisy instance (e.g. siteA, siteB and siteC). These sites are addressed via the following URLs:

http://mydaisysite.tld/daisy/siteA
http://mydaisysite.tld/daisy/siteB
http://mydaisysite.tld/daisy/siteC

While this concept will appropriate  in many cases, one might have the requirement to use daisy for a site which comprises a single topic only. In that case, one might wish to hide the "siteY" string from the URL completely. This article explains how to implement this by use of the apache mod_rewrite module. This approach can be also useful for daisy instances with multiple sites, e.g. if you would like to redirect directly to a default site rather than presenting an overview page containing a list of links pointing to all your daisy sites (which is the default behaviour of a fresh daisy installation).

This article assumes that you have mod_rewrite loaded/enabled inside your apache webserver and that you are connecting to jetty via mod_jk as described here.

Next define a virtual host (with some of the settings adapted to your needs, of course):

<VirtualHost www.mydaisysite.tld:*>
      ServerName www.mydaisysite.tld
	
      ## Configure ServerAdmin, Log Options ... here
    
      DocumentRoot /var/www/html/mydaisysitedirectory
      ErrorDocument 500 /noservice.html
      ErrorDocument 503 /noservice.html

      ## If the requested URI is located in the resources folder, do not forward the request
      SetEnvIfNoCase Request_URI ^/noservice.html$ no-jk
      SetEnvIfNoCase Request_URI ^/admin/resources/js/.*$ no-jk
      SetEnvIfNoCase Request_URI ^/siteA/resources/js/.*$ no-jk
      SetEnvIfNoCase Request_URI ^/siteB/resources/js/.*$ no-jk

      ## also, we have to serve images and css statically now
      SetEnvIfNoCase Request_URI ^/resources/conf/.*$ no-jk
      SetEnvIfNoCase Request_URI ^/resources/skins/default/images/.*$ no-jk
      SetEnvIfNoCase Request_URI ^/resources/skins/default/css/.*$ no-jk
      SetEnvIfNoCase Request_URI ^/resources/skins/skinA/images/.*$ no-jk
      SetEnvIfNoCase Request_URI ^/resources/skins/skinA/css/.*$ no-jk      

      ## define static custom contents that are delivered from apache
      SetEnvIfNoCase Request_URI ^/documentA.pdf$ no-jk
      SetEnvIfNoCase Request_URI ^/documentB.pdf$ no-jk
 
      RewriteEngine on

      ## the following daisy URLs must be excluded from the rewrite 
      RewriteCond %{REQUEST_URI} !^.*/resources/.*$
      RewriteCond %{REQUEST_URI} !^/admin.*$
      RewriteCond %{REQUEST_URI} !^/confirmRegistration.*$
      RewriteCond %{REQUEST_URI} !^/registration.*$
      RewriteCond %{REQUEST_URI} !^/locale.*$
      RewriteCond %{REQUEST_URI} !^/books.*$
      RewriteCond %{REQUEST_URI} !^/doctask.*$
      RewriteCond %{REQUEST_URI} !^/login$
      RewriteCond %{REQUEST_URI} !^/passwordReminder.*$
      RewriteCond %{REQUEST_URI} !^/loginReminder.*$
      RewriteCond %{REQUEST_URI} !^/selectRole.*$
      RewriteCond %{REQUEST_URI} !^/selectUser.*$
      RewriteCond %{REQUEST_URI} !^/usersettings.*$

      ## if you defined static contents, you must exclude them
      RewriteCond %{REQUEST_URI} !^/noservice.html$
      RewriteCond %{REQUEST_URI} !^/documentA.pdf$
      RewriteCond %{REQUEST_URI} !^/documentB.pdf$

      ## if you want to define more than one site, all sites
      ## other than the default site have to be excluded, too
      RewriteCond %{REQUEST_URI} !^/siteB.*$
      RewriteCond %{REQUEST_URI} !^/siteC.*$

      ## rewrite any URL to siteA (your default site)
      RewriteRule !^/siteA/(.*)$ /siteA%{REQUEST_URI} [PT]

      ## prevent error after login (due to jessionid in URL)
      RewriteRule ^(.*);jsessionid=.*$ $1 [PT]
      
      ## worker as defined in worker.properties
      JkMount /* yourSiteWorker 
    
</VirtualHost>

Restart your apache webserver (the comments inside the text hopefully allow you to adjust everything to your needs!)

Your page layout might look pretty screwed now. This is due to the rewrite rule, all links in your html-pages pointing to the images and css-files inside the resources directory are broken now. Rather than fixing this inside the sitemap.xmap (which gets overwritten at any upgrade), we serve the contents of the resources directories statically from apache now (the corresponding settings for that are inside the virtual host definition above!). In order to make the links work again, you must create a resources directory and a directory for each of your sites inside the document root directory of your apache virtual host:

/Path_TO_DOCUMENTROOT$ mkdir resources
/Path_TO_DOCUMENTROOT$ mkdir siteA
/Path_TO_DOCUMENTROOT$ mkdir siteB

Then, inside the resources directory, set the following links:

/Path_TO_DOCUMENTROOT/resources$ ln -s /DAISY_HOME/daisywiki/webapp/daisy/resources/cocoon/ .
/Path_TO_DOCUMENTROOT/resources$ ln -s /DAISY_HOME/daisywiki/webapp/daisy/resources/conf/ .
/Path_TO_DOCUMENTROOT/resources$ ln -s /DAISY_HOME/daisywiki/webapp/daisy/resources/js/ .
/Path_TO_DOCUMENTROOT/resources$ ln -s /DAISY_HOME/daisywiki/webapp/daisy/resources/skins/ .

Inside each of your site directories, simply link to the resources directory one hierarchy below:

/Path_TO_DOCUMENTROOT/siteA$ ln -s ../resources .
/Path_TO_DOCUMENTROOT/siteB$ ln -s ../resources .

That's it.
Enjoy!

Comments (0)
Advertisement

Daisy hosting, installation, support. Workshops and turnkey Daisy CMS projects. Get Daisy from its creators.

outerthought.org

Downloads provided by

SourceForge.net Logo

Open source stats