(Long) Rewrite Rules for Wiki (was Re: Wiki)

From: Randy Kramer <rhkramer_at_gmail.com>
Date: Thu Mar 03 2005 - 17:42:25 CET

On Thursday 03 March 2005 08:46 am, Randy Kramer wrote:
> On Wednesday 02 March 2005 08:42 pm, Alan Horkan wrote:
> I'll write a separate email describing what I do (or think I) know, and
> look for some help to get the rewrite rules firmed up.

This may be a little long. I'd suggest people interested in choosing the form
of the shortened URLs read (or skim) up through and including the digressions
(i.e., to my "signature"). Gluttons for punishment can read the PS as well.

First I want to mention some general criteria that we have to consider as we
create rewrite rules:

   * We need to make sure the rules allow "old style" URLs to continue to work
properly. This is because the TWiki itself "generates" URLs at various times
(simplest example, when we click edit, a URL like: (for example)


(for example) is issued (note the word "edit").

If we do anything to prevent that URL from working, we'll have to rewrite the
parts of TWiki that generate those URLs, and I for one, neither have the
expertise to do that, nor want to try (with the first of order of business to
learn Perl).

There are quite a few alternatives we might see in place of edit: view (for
the normal view), preview, oops (to report errors), statistics, search, ...
The only style of URL we want to rewrite are the view URLs (and perhaps the
viewauth URLs if we ever create write protected pages). Here's an example
view URL (note the word "view"):


   * We need to be careful about name conflicts with the "base" (non-wiki)
abisource site (I'm "thinking out loud" about this as I write--I'm going to
go get a sample URL from the base site and paste it here):


I hope that's fairly typical--if it is things won't be (quite) as difficult as
I expected--I was concerned about name conflicts between the "main" site and
the wiki, but based on this example, we could set the rewrite rules to make
wiki URLs look like this:


(to be rewritten as:


What is the key difference between wiki and non-wiki URLs? At the moment it
looks like we might be able to focus on capitalized words--WebHome should be
rewritten to go to the wiki, information/about/ should not. (I'll try to do
a little more checking on the web site to see if there are capitalized page
names on the main (i.e., non wiki) abisource site (after I send this email).)

Some Digressions:

   * We could include the (wiki) web name (Abiword) in the URL to be
rewritten, i.e., we could rewrite URLs that look like this:


to be rewritten as:


But, it seems like that is not really necessary based on two premises:

      * Capitalized page names are not used on the main (non wiki) abisource
site (to be confirmed)
      * Few people, if any, besides someone like myself, will want to access
pages in any of the other webs. So, if someone wants that access, they use
the old (long form) URL which we must keep working anyway. Thus we maximize
the convenience for the vast majority of users.

   * If capiitalized page names are used on the main (non-wiki) abisource
site, then we have a few alternatives:

      * Include the web name to help distinguish from main site web pages,
e.g., use:


      * Include some other means of distinguishing wiki and non-wiki pages,
perhaps including the word wiki (or w, or supercalafradulisticexpialidocious)
like this:


   * Use (get) a different (sub) domain name:

http:// faq.abisource.com/WebHome, or
http:// wiki.abisource.com/WebHome, or

What I Know about Rewrite Rules:

(not very much ;-)

In fact, I mispoke when I said I tried to use rewrite rules on my TWiki a few
years ago, I actually tried to use script aliases. I made some progress, but
could not accomplish all I wanted to (at the time, I wanted to shorten the
URLs for all the TWiki URLs, i.e., edit, preview, oops, statistics, etc. in
addition to view--as discussed above, I don't think that's necessary, and
avoiding that will make things simpler).

The best article I've found on rewrite rules is the following (but I haven't
read it thoroughly enough to fully understand it):


I'm really hoping someone on this list has enough knowledge to generate the
proper rewrite rules once we get a consensus on what the "target" URL should
be (i.e.

http://www.abisource.com/WebHome, or
http://www.abisource.com/Abiword/WebHome, or
http://www.abisource.com/wiki/WebHome, or
http:// faq.abisource.com/WebHome, or
http:// wiki.abisource.com/WebHome, or

(Recognizing that WebHome represents a generic (probably capitalized) page
name, i.e., the rewrite rules have to deal with any (wiki) page name.)

Randy Kramer


Resources from twiki.org

At one point I promised Hubert I'd review twiki.org to find relevant
references to rewrite rules (and/or script aliases). I collected the
following but never sent them to Hubert (they probably could stand some

* http://twiki.org/cgi-bin/view/Codev/ShorterURLs --
appears to be the "canonical" page (at least on twiki/Codev) with respect to
using rewrite rules to create shorter URLs. There is a gotcha with respect
to viewauth (viewauth is used for restricting the viewing of pages, view is
for non-restricted viewing, and, I don't believe viewauth is in use on the
AbiWord wiki). -- PS: Near the bottom of the page (see
there is an alternate approach involving some changes in the .httpd.conf
file--I had tried something similar once, but was not successful--the
approach described here may work, as, iirc, he has added an extra alias line
which I had not tried.

* http://twiki.org/cgi-bin/view/Support/MungingWebAddress -- someone else's
attempt to do the same thing under a slightly different web / server setup --
if the instructions in the above link don't work, there may be a clue here

-- more about at least part of the viewauth problem -- "Bug: Redirection from
view to viewauth can fail if the RewriteEngine is used -- The function view
in lib/TWiki/UI/View.pm assumes that REQUEST_URI contains "/view". If URIs
are rewritten using Apache's RewriteEngine, this assumption is not
necessarily true, resulting in a redirection endless loop."

* http://twiki.org/cgi-bin/view/Codev/ShorterCaseInsensitiveURLs -- from what
I read (here) on case insensitive URLs, I'm not sure I'd recommend using them

* http://twiki.org/cgi-bin/view/Wikilearn/BetterURLs -- a page I had started
once to record resources relevant to creating shorter URLs -- I think I've
listed the most useful links above (at least those within twiki)

* These next two links reflect my attempts to get shorter URLs via Aliases and
Script Aliases--what I got to were links of the form . I had some success,
but not what I really was looking for. Included only for the possibility
that you want to pursue that route, the instructions somewhere above don't
work, and there is some clue buried in this garbage.<br /> <br />

** This page records my initial attempts and failures:
http://twiki.org/cgi-bin/view/Codev/RenameViewToAview<br /> <br />
** This page reflects an attempt at a restart, but still not totally
http://twiki.org/cgi-bin/view/Codev/RenameViewToAviewWorking --
Received on Thu Mar 3 17:45:14 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2005 - 17:45:14 CET