]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/tips/redirections_for_usedirs.mdwn
add pagespec/sorting to underlay
[git.ikiwiki.info.git] / doc / tips / redirections_for_usedirs.mdwn
1 Want to turn on the `usedirs` setting on an existing wiki without breaking
2 all the links into it?
4 #Apache and RewriteEngine
6 Here's a way to do it for Apache, using the
7 RewriteEngine. This example is for a wiki at the top of a web site, but can
8 be adapted to other situations.
10         # pages
11         RewriteCond $1 !^/~          # these pages
12         RewriteCond $1 !^/doc/       # are not part of
13         RewriteCond $1 !^/ajaxterm   # the wiki, so
14         RewriteCond $1 !^/cgi-bin/   # don't rewrite them
15         RewriteCond $1 !.*/index$
16         RewriteRule (.+).html$ $1/ [R]
17         
18         # rss feeds
19         RewriteCond $1 !^/~
20         RewriteCond $1 !.*/index$
21         RewriteRule (.+).rss$ $1/index.rss
22         
23         # atom feeds
24         RewriteCond $1 !^/~
25         RewriteCond $1 !.*/index$
26         RewriteRule (.+).atom$ $1/index.atom
28 #lighttpd and mod_redirect
30 The following example is exactly the same thing written for lighttpd by using mod_redirect:
32     $HTTP["url"] !~ "^/(~|doc/|ajaxterm|cgi-bin/)" {
33       $HTTP["url"] !~ "^/(.*/index\.(html|rss|atom))" {
34         url.redirect = ( 
35           "(.*)\.html$" => "$1/",
36           "(.*)\.(atom|rss)$" => "$1/index.$2"     
37         )
38       } 
39     }