Modrewriting viewcvs to viewvc in Apache2

|

I have been using viewcvs to provide source browser to Voyage Linux source codes for a few years. After Debian upgrade, viewcvs is now (seemlessly) replaced by viewvc. The upgrade is not the trouble although there are some re-configurable issue I had to deal with. The most painful part is that the original /cgi-bin/viewcvs.cgi/ URL no longer available and has changed to /cgi-bin/viewvc.cgi/ that makes all the reference link broken.

In order to provide backward compatibility to the original URL so that I have no need to modify all the cvs URL in Voyage Linux web site, I decided to use modrewrite to rewrite /cgi-bin/viewcvs.cgi/ to /cgi-bin/viewvc.cgi/. So I edit my virutal host configuration file to add:

RewriteEngine On
RewriteRule ^/cgi-bin/viewcvs.cgi(.*) /cgi-bin/viewvc.cgi$1 [R]

I tried without the "redirect" [R] option, but won't work. It works only if I set it as redirection rather than rewrite. So when you test http://cvs.voyage.hk/cgi-bin/viewcvs.cgi/, it is now being redirected to http://cvs.voyage.hk/cgi-bin/viewvc.cgi/ now.

There is a side issue in the upgrade. After upgrade, the viewvc image files are not accessible and return 404. For example if I access http://cvs.voyage.hk//cgi-bin/viewvc.cgi/*docroot*/images/logo.png", I got the following:

An Exception Has Occurred

Static file "images/logo.png" not available
([Errno 2] No such file or directory: '/usr/lib/templates/docroot/images/logo.png')

HTTP Response Status

404 Not Found

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/viewvc/viewvc.py", line 3766, in main
    request.run_viewvc()
  File "/usr/lib/viewvc/viewvc.py", line 183, in run_viewvc
    return view_doc(self)
  File "/usr/lib/viewvc/viewvc.py", line 2342, in view_doc
    % (document, str(v)), '404 Not Found')
ViewVCException: 404 Not Found: Static file "images/logo.png" not available
([Errno 2] No such file or directory: '/usr/lib/templates/docroot/images/logo.png')
After searching, I found this debian bug report very useful. The key is to give the template dir an absolute path:
#self.options.template_dir = "templates"
self.options.template_dir = "/etc/viewvc/templates"
And this solve the final issue I have with viewvc.