Question
In the
TWikiAccessControl document under the 'Controlling access to Attachments' section it discusses how to have documents published under the /pub directory be processed by the bin/viewfile script. Does anyone have this working? I've been reading the apache rewrite documentation but can't seem to get the rewrite rule to work correctly so I thought I'd see if others had it working at all.
Environment
--
RobLeach - 12 Jun 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
I did some experiments with it.
One thing I found out.
Rewrite rules written at a global level in httpd.conf or in a file included from httpd.conf are not valid inside a virtual host.
To make it work I had to include a twiki.conf file that contains the twiki config including the rewrite rules from within the virtual host section.
Example in httpd.conf
<VirtualHost *:80>
ServerName www.mydomain.com
Include /var/www/twiki.conf
</VirtualHost>
And the twiki.conf is then not included inside the global part of httpd.conf
In the twiki.conf you can then put the rewrite rules.
I did not finish testing this to the end but the syntax is something like
RewriteEngine on
RewriteRule ^/twiki/pub/TWiki/(.*)$ /twiki/pub/TWiki/$1 [L,PT]
RewriteRule ^/twiki/pub/(.*\.gif)$ /twiki/pub/$1 [L,PT]
RewriteRule ^/twiki/pub/([^\/]+)/([^\/]+)/([^\/]+)$ /twiki/bin/viewfile/$1/$2?filename=$3 [L,PT]
viewfile is very slow compared to the direct access to pub so you do not want all the css files, javascript files, graphics files etc to be loaded with viewfile. Only the real attachments in your own Webs. Otherwise TWiki will becomes very slow.
--
KennethLavrsen - 24 Jun 2006