Changes between Version 12 and Version 13 of TracPrettyUrls
- Timestamp:
- Feb 18, 2015, 5:37:59 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracPrettyUrls
v12 v13 1 = Prettier URLs for Trac =1 = Prettier URLs for Trac 2 2 3 If you would like the url to be like:3 There are several ways to obtain clean URLs in Apache: 4 4 5 http://<yourhostname>/ 5 `http://<yourhostname>/` 6 6 7 or (maybe with a subdomain): 7 `http://<subdomain>.<yourhostname>/` 8 8 9 http://<subdomain>.<yourhostname>/ 9 == Using mod_rewrite through httpd.conf 10 10 11 there are several ways to do this on Apache: 12 13 === Using mod_rewrite through httpd.conf === 14 If you have access to your Apache config, load the module mod_rewrite, then, place this in the config: 15 (if you have subdomain, inside a !VirtualHost) 11 If you have access to your Apache config, load the module `mod_rewrite`, then place this in the config: 16 12 17 13 {{{ … … 28 24 }}} 29 25 30 Or using !ScriptAliasMatch you can redirect all request coming to / without rewriting the URL to the user: 26 If you have a subdomain, it should go inside !VirtualHost tags, see [http://httpd.apache.org/docs/ Apache documentation]. 27 28 Or using !ScriptAliasMatch you can redirect all request coming to `/` without rewriting the URL to the user: 31 29 32 30 {{{ … … 36 34 }}} 37 35 38 === Using mod_rewrite from .htaccess files === 39 Make an .htaccess file or add the following lines into existing if it's already present in your site directory with trac.fcgi 36 == Using mod_rewrite from .htaccess files 37 38 Make an .htaccess file or add the following lines into existing if it's already present in your site directory with trac.fcgi: 40 39 {{{ 41 40 RewriteEngine On … … 46 45 }}} 47 46 48 Two RewriteCond strings tell Apache do not fire redirection to Trac script if there is existing file or directory with requested name. The last rule works always and redirects root site requests to 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. 47 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. 48 49 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: 49 50 {{{ 50 51 RewriteCond %{REQUEST_URI} !^/(stats/|phpmyadmin) [NC] 51 52 }}} 52 53 53 === Easy access URL as a last resort === 54 The above configurations of Apache will not allow 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: 54 == Easy access URL as a last resort 55 56 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: 55 57 56 58 {{{<META HTTP-EQUIV="Refresh" CONTENT="0; URL=/cgi-bin/trac.cgi">}}} 57 59 58 or put the following in /usr/share/trac/htdocs/index.php if your server supports php to enable a transparent redirect. 60 Or put the following in /usr/share/trac/htdocs/index.php if your server supports PHP to enable a transparent redirect: 59 61 <?php 60 62 header("Location: /cgi-bin/trac.cgi"); … … 62 64 63 65 ---- 64 See also: TracInstall, TracMultipleProjects, [http:// projects.edgewall.com/trac/wiki/TracFaq#how-can-i-create-a-nice-url-to-access-trac-cgi TracFaq: "How can I create a nice URL to access trac.cgi?"]66 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?"]