aboutsummaryrefslogtreecommitdiff
path: root/doc/tips/redirections_for_usedirs.mdwn
blob: 2913691f0c27a4df7f933afa17dbd00f0b23e25f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Want to turn on the `usedirs` setting on an existing wiki without breaking
all the links into it? Here's a way to do it for Apache, using the
RewriteEngine. This example is for a wiki at the top of a web site, but can
be adapted to other situations.

	# pages
	RewriteCond $1 !^/~          # these pages
	RewriteCond $1 !^/doc/       # are not part of
	RewriteCond $1 !^/ajaxterm   # the wiki, so
	RewriteCond $1 !^/cgi-bin/   # don't rewrite them
	RewriteCond $1 !.*/index$
	RewriteRule (.+).html$ $1/ [R]
	
	# rss feeds
	RewriteCond $1 !^/~
	RewriteCond $1 !.*/index$
	RewriteRule (.+).rss$ $1/index.rss
	
	# atom feeds
	RewriteCond $1 !^/~
	RewriteCond $1 !.*/index$
	RewriteRule (.+).atom$ $1/index.atom

The following example is exactly the same thing written for lighttpd by using mod_redirect:

    $HTTP["url"] !~ "^/(~|doc/|ajaxterm|cgi-bin/)" {
      $HTTP["url"] !~ "^/(.*/index\.(html|rss|atom))" {
        url.redirect = ( 
          "(.*)\.html$" => "$1/",
          "(.*)\.(atom|rss)$" => "$1/index.$2"     
        )
      } 
    }