Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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 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 =
use_base_url_for_redirect = true

had no effect.

share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.