Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

 
discard

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.