0

How do I convince trac to omit trac.cgi from its internal links?

I have a trac instance deployed in a user directory using htaccess and mod_rewrite, and would like the URLs to be of the form http://example.com/foo/ticket/1. Editing the server config is not possible.

My user web directory contains

$ ls -A foo
.htaccess trac.cgi

.htaccess contains what is recommended on the Trac website:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ trac.cgi/$1 [L,QSA]

RewriteRule ^$ trac.cgi [L]

This is partially successful, as I can go to http://example.com/foo/ticket/1 and get the correct page. However, all links that Trac generates on its Wiki pages still include 'trac.cgi'. The page source trac generates has links like

<a href="/foo/trac.cgi/wiki/WikiStart">

I tried to find out how trac determines the base URL to use, but was unsuccessful. Editing trac.ini with

base_url = http://example.com/foo/
use_base_url_for_redirect = true

had no effect.

1 Answers1

0

It seems this is an open Trac issue (Trac ticket 2299), and a workaround for now is to edit trac.cgi and add the line

 os.environ['SCRIPT_NAME'] = "/foo"

That fixed it for me.