<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>redirections for usedirs</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="../style.css" type="text/css" /> <link rel="stylesheet" href="../local.css" type="text/css" /> </head> <body> <div class="page"> <div class="pageheader"> <div class="header"> <span> <span class="parentlinks"> <a href="../index.html">ikiwiki</a>/ <a href="../tips.html">tips</a>/ </span> <span class="title"> redirections for usedirs </span> </span> </div> </div> <div id="pagebody"> <div id="content" role="main"> <p>Want to turn on the <code>usedirs</code> setting on an existing wiki without breaking all the links into it?</p> <h1>Apache and RewriteEngine</h1> <p>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.</p> <pre><code># 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 </code></pre> <h1>lighttpd and mod_redirect</h1> <p>The following example is exactly the same thing written for lighttpd by using mod_redirect:</p> <pre><code>$HTTP["url"] !~ "^/(~|doc/|ajaxterm|cgi-bin/)" { $HTTP["url"] !~ "^/(.*/index\.(html|rss|atom))" { url.redirect = ( "(.*)\.html$" => "$1/", "(.*)\.(atom|rss)$" => "$1/index.$2" ) } } </code></pre> </div> </div> <div id="footer" class="pagefooter" role="contentinfo"> <div id="pageinfo"> <div id="backlinks"> Links: <a href="./howto_avoid_flooding_aggregators.html">howto avoid flooding aggregators</a> <a href="./switching_to_usedirs.html">switching to usedirs</a> </div> <div class="pagedate"> Last edited <span class="date">Tue Feb 26 23:01:54 2019</span> <!-- Created <span class="date">Wed Apr 11 01:17:05 2007</span> --> </div> </div> <!-- from ikiwiki --> </div> </div> </body> </html>