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