Edgewall Software
Home
Trac
Trac Hacks
Genshi
Babel
Bitten
Home
Download
Documentation
Mailing Lists
License
FAQ
Search:
Login
Preferences
Help/Guide
About Trac
Wiki
Timeline
Roadmap
Browse Source
View Tickets
New Ticket
Search
Context Navigation
+0
Start Page
Index
History
Editing TracPrettyUrls
Adjust edit area height:
8
12
16
20
24
28
32
36
40
Edit side-by-side
= Prettier URLs for Trac There are several ways to obtain clean URLs in Apache: `http://<yourhostname>/` `http://<subdomain>.<yourhostname>/` == Using mod_rewrite through httpd.conf If you have access to your Apache config, load the module `mod_rewrite`, then place this in the config: {{{ RewriteEngine On <Location "/cgi-bin/trac.cgi"> SetEnv TRAC_ENV "/path/to/trac/env" </Location> ServerName <hostname> Alias /trac "/usr/share/trac/htdocs" ScriptAlias /cgi-bin /path/to/cgi-bin RewriteRule ^/$ /cgi-bin/trac.cgi [R] }}} If you have a subdomain, it should go inside !VirtualHost tags, see [http://httpd.apache.org/docs/ Apache documentation]. Or using !ScriptAliasMatch you can redirect all request coming to `/` without rewriting the URL to the user: {{{ SetEnv TRAC_ENV "/var/to/trac" ScriptAliasMatch ^/(.*) /path/to/trac.cgi/$1 }}} == Using mod_rewrite from .htaccess files Make an .htaccess file or add the following lines into existing if it's already present in your site directory with trac.fcgi: {{{ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /trac.fcgi/$1 [L,QSA] RewriteRule ^$ trac.fcgi [L] }}} The !RewriteCond strings tell Apache to not fire redirection to Trac script if there is an existing file or directory with the requested name. The last rule works always and redirects root site requests to the TracCGI script. If you want to explicitly exclude some paths from being handled by Trac, such as /stats URLs or /phpmyadmin etc. usually provided by hostings, then insert the third !RewriteCond right after the second one: {{{ RewriteCond %{REQUEST_URI} !^/(stats/|phpmyadmin) [NC] }}} == Easy access URL as a last resort The above configurations of Apache will not allow the user to see "cgi-bin" or "trac.cgi" string in Trac URLs. However, if you just want to automatically redirect users from your site root to trac page - put a redirect in {{{/usr/share/trac/htdocs/index.html}}}, such as: {{{<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/cgi-bin/trac.cgi">}}} Or put the following in /usr/share/trac/htdocs/index.php if your server supports PHP to enable a transparent redirect: <?php header("Location: /cgi-bin/trac.cgi"); ?> ---- See also: TracInstall, TracMultipleProjects, [http://trac.edgewall.org/wiki/0.12/TracFaq#how-can-i-create-a-nice-url-to-access-trac-cgi TracFaq: "How can I create a nice URL to access trac.cgi?"]
Note:
See
WikiFormatting
and
TracWiki
for help on editing wiki content.
Change information
Your email or username:
E-mail address and name can be saved in the
Preferences
Comment about this change (optional):
Note:
See
TracWiki
for help on using the wiki.