Tags:
archive_me2Add my vote for this tag delete_me1Add my vote for this tag installation1Add my vote for this tag url3Add my vote for this tag usability3Add my vote for this tag create new tag
view all tags
  1. Most of the work in this section was contributed by RobNapier around 30 May 2002;
  2. This page is just a lead-up to the instructions on ShorterUrlCookbook. Go there instead.

Executive Summary

Maybe it's just me, but I find the Twiki URLs too long. I particularly don't like the '.../bin/viewauth/...' part that shows up so much.

The idea is to align TWiki with Tim Berners-Lee's note on how to design URIs: http://www.w3.org/Provider/Style/URI.html, that every part of the URL has meaning

  • Action
  • Namespace
  • Page

Have you managed to get ShorterURLs to work for you using httpd.conf?
Do you agree or disagree? Please select one of the radio buttons below and click the button.
I 1 - Strongly disagree   2 - Disagree   3 - am Neutral   4 - Agree   5 - Strongly Agree  


1 DavidWolfe 23 May 2008 I cannot get my head wrapped around the very little documentation that seems to exist about how to do this.

4 BeomsuChang 23 May 2008  

5 CarlaFreitas 30 Apr 2007  

2 JoachimSchrod 26 Apr 2007 Works, but not with the information from this page.
ShorterUrlCookbook is clear and concise, this topic confuses.
5 SergejZnamenskij 09 Jan 2007 Works fine for us (http://wiki.botik.ru) too.
5 WoutMertens 08 Jan 2007 Works just fine for us... People find it easier to understand.
4 AndrewRJones 08 Sep 2006 Method described in ShorterUrlCookbook
4 OleCMeldahl 03 Apr 2006  
2 TorbenGB 29 Jul 2005 No, I'm using a hosted service so I can't access httpd.conf.
5 JonathanGraehl 08 Dec 2004 After extensive futzing and RewriteEngine-log-watching, yes

Have you managed to get ShorterURLs to work for you using .htaccess?
Do you agree or disagree? Please select one of the radio buttons below and click the button.
I 1 - Strongly disagree   2 - Disagree   3 - am Neutral   4 - Agree   5 - Strongly Agree  


5 StefanoCiccarelli 21 May 2005  
4 TorbenGB 14 Feb 2005 Yes, on entering shorter URLs in the address bar, but once a user clicks onward inside the wiki, the URLs are the normal long ones. But I don't use the method described here; instead, just a simple hack: RewriteRule ^([A-Z].*) /bin/view/$1
5 MartinCleaver 09 Nov 2004 Works for me on my Cairo installs

Motivation

Long URLs are much harder for me to rattle off to someone on the phone and make sure they get it right. This is a common cause of confusion among non-techincal users.

Method

  • This assumes the rewrite engine is turned on. See under #AlterNatives if you do not want to do that.

This is a brief discussion of how I addresed this issue through Apache rewrite rules. I manage my own virtual domain, so this lets me get all the way down to URLs like:

http://www.ranjan.org/Main/RobNapier


You also need to set $scriptUrlPath to '' in TWiki.cfg.

Things of note:

  • You never have to update these rules, even with an upgrade to TWiki.

Notes

  • This scheme is compatible with non-TWiki directories living in the same tree, as long as none of the top level directories have the same name as either a web or a TWiki script. That's a reasonably good bet.

Further Development

  • For safety, this scheme always assumes viewauth if no script is given. If you need viewauth and you use view, you'll get into an infinite loop. Changes to view itself might fix this, but for me it's not worth the hack. If you're interested in doing this some other way, look at view around line 169. This is where the view->viewauth conversion happens. You'll need to make sure that you inject 'viewauth' even if 'view' isn't in the original URI. Doing this will probably make your system very site-specific. For me, I'd rather just always force authentication and press on.
  • For another version of this that also makes the URLs case-insensitive, see ShorterCaseInsensitiveURLs.
  • The now dead TWiki fork O'Wiki implemented this as part of the chaos branch. The approach taken was to eradicate all the binaries (except for compatibility stubs), to have a single cgi (CommonFrontEndCgiScript), and user interaction code layer, and then an error document handler that redirected to either a precompiled view if available (and fresh enough) or simply serves up the "missing" page. -- MS - 20 Nov 2003

.htaccess file vs. httpd.conf

httpd.conf

Original Apache 1.x version

Use the following rewrite rules (in a Virtualhost section of httpd.conf):

RewriteEngine on

# If we used a topic or web name, rewrite it into viewauth
RewriteCond %{REQUEST_FILENAME} !/twiki/
RewriteCond /home/rnapier/public_html/twiki/data%{REQUEST_FILENAME}.txt -f [OR]
RewriteCond /home/rnapier/public_html/twiki/data%{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /twiki/bin/viewauth$1

# If we used a script name, rewrite it into twiki/bin
RewriteCond %{REQUEST_FILENAME} !/twiki/
RewriteCond %{REQUEST_FILENAME} ^/([^/]+)/
RewriteCond /home/rnapier/public_html/twiki/bin/%1 -f
RewriteRule ^/[^/]+/(.*)$ /twiki/bin/%1/$1 [PT]

Authoratative Version for Apache 2.0

Well, here's my version (Apache 2 mod_rewrite), which doesn't pass through to any Alias or ScriptAlias directive. I did add AcceptPathInfo to my script dir, although it shouldn't be necessary for the mod_perl or CGI handlers. The earlier configuration examples simply did not work for me (although I confess I could have mangled something).

Aside from shortening URLs only when there's no ambiguity with files in htdocs, it shortens view URLs with a ?topic= argument (e.g. from typing a topic name into the "Go" field, and directs TWiki web views to a viewpub script (view, the default script for other webs, is auth-required in my setup; this gives about a 30% performance increase due to no redirect). Note that redirects are used to automagically shorten the user-visible URLs, even if you don't make any changes to TWiki core/templates to actually use the $dispViewPath variable in TWiki.cfg.

Obviously, s|/home/graehl/isd/twiki|/your/path/to/twiki| and s|/home/graehl/isd/htdocs|/your/htdocs| ...

One huge bug that took me a while to track down was the ErrorDocument 401 /twiki/bin/oops... I had in my bin .htaccess. DO NOT point to an errordocument URL that gets redirected, or else the browsers won't prompt for username/password. It took me hours of poking around, searching the web/news, etc. to no avail, when the problem was that I had an ErrorDocument pointing to the longer URL, which I rewrote/redirected



<Directory "/home/graehl/isd/twiki/bin">
    Options +ExecCGI
    AcceptPathInfo On
    SetHandler cgi-script
    AllowOverride all
    Allow from all
</Directory>

  RewriteRule ^/twiki/(pub/.*)$ /home/graehl/isd/twiki/$1 [L]

#### SHORTER URL SUPPORT
#### be careful not to set your ErrorDocument 401 /twiki/bin/oops... or else you won't actually be prompted for a password!
#### set it instead to the short URL /oops...  RewriteCond %{REQUEST_URI} ^\/twiki/bin/view/(.*)$
  RewriteCond /home/graehl/isd/htdocs/%1 !-f
  RewriteRule .* %1 [R=permanent,L] 

  RewriteCond %{REQUEST_URI} ^\/twiki/bin/(.*)$
  RewriteCond /home/graehl/isd/htdocs/%1 !-f
  RewriteRule .* %1 [R=permanent,L] 
## NOW REDIRECTED TO SHORTER (note: url only shortened if it wouldn't be ambiguous with a doc in htdocs root)


  RewriteCond /home/graehl/isd/htdocs/%{REQUEST_URI} -f [OR]
  RewriteCond /home/graehl/isd/htdocs/%{REQUEST_URI} -d
  RewriteRule . - [L]
## now sure that short URL is meant for twiki

  RewriteCond %{REQUEST_URI} ^\/view/(.*)$
  RewriteCond /home/graehl/isd/htdocs/%1 !-f
  RewriteRule .* %1 [R=permanent,L] 

  RewriteCond %{REQUEST_URI} ^\/([^\/]*)
  RewriteCond /home/graehl/isd/twiki/bin/%1 -f
  RewriteRule .* /twiki/bin%{REQUEST_URI}

##
  RewriteCond %{REQUEST_URI} ^(\/[^/]+)
  RewriteCond /home/graehl/isd/twiki/data%1 -d 
  RewriteCond /home/graehl/isd/twiki/data%{REQUEST_URI}.txt -f [OR]
  RewriteCond /home/graehl/isd/twiki/data%{REQUEST_URI} -d [OR]
  RewriteRule .* /twiki/bin/view%{REQUEST_URI}
## have to view not-found (new) topics in a found web, existing text topics, and existing dirs

#### (URLS ARE NOW FULL (/twiki/bin/(view|edit...) AGAIN)

##
  RewriteCond %{QUERY_STRING} ^topic=([^.]*)\.(.*)$
  Rewriterule ^/twiki/bin/view /view/%1/%2? [R=permanent,L]

  RewriteCond %{QUERY_STRING} ^topic=([^.]*)$
  Rewriterule ^/twiki/bin/view/([^/]*)/.*$ /view/$1/%1? [R=permanent,L]
## VIEW blah blah with topic= (from typing topic name in Go box) gets redirected to pretty/short URL


  Rewriterule ^/twiki/bin/view/(TWiki/.*)$ /home/graehl/isd/twiki/bin/viewpub/$1 [L]
# only this web isn't authentication-required in .htaccess

  Rewriterule ^/twiki/bin(.*)$ /home/graehl/isd/twiki/bin$1 [L]
# instead of alias or scriptalias

-- JonathanGraehl - 15 Jul 2004

In order for the Go/Jump: feature to work with undefined topics, I had to make a couple of edits to TWiki/UI/View.pm. I've attached the patch below as GoUndefined-20041122.patch. Patches are against 20040902 release.

-- DiabJerius - 22 Nov 2004

I run a site which hosts multiple TWiki's off of the same server, without using Virtual Hosts. I've modified the above rewrite rules to accomodate that setup. You can find them in MultiTwikiShorterURLs

-- DiabJerius - 24 Nov 2004

.htaccess

I'm just in the process of setting up a new TWiki and would sure love to be able to implement ShorterURLs! Unfortuately, being a hosted site, I don't have access to httpd.conf. It sure would be nice if someone could figure out a simple way to achieve this since it really seems un-necessarily messy to have the cgi-bin/edit part in every url. IMHO This is a basic usability feature that should be addressed in the TWiki core.

-- LynnwoodBrown - 28 Sep 2003

Lynnwood, see if the workaround in RedirectIndexToTWiki can be adapted for this (and report back if works!)

-- MattWilkie - 10 Oct 2003

Apache 1.x, TWiki20040901 and .htaccess

I've installed ShorterURLs on my TWiki20040901 installation with a .htaccess file but find that clicking on links takes me to http://site/view/Web/Topic not http://site/Web/Topic.

Does anyone else see this? I think it is a consequence that we install under URL /twiki instead of at /

In any case, it would be good to have a tool that configures .htaccess throughout an installation.

-- MartinCleaver - 05 Sep 2004

One thing I discovered today: if you have Options ExecCGI in bin/.htaccess this will stop your /.htaccess file working!

Symptom: I was getting the error:

Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden

Taking it out worked... I suspect that it is actually that you need all of:

Options +FollowSymLinks +SymLinksIfOwnerMatch ExecCGI 

operational throughout the site.

-- MartinCleaver - 20 Oct 2004

Authorative version for Apache 1.x and twiki-20030201-4

I have tried a combination of the methods (listed on the prefactored page) and finally have found a solution working for me. My TWiki version is the package twiki-20030201-4 coming with debian sarge. My setup is: a virtual host completely managed by TWiki for which I want URLs to be http://my.host.ext/Main/Foo or http://my.host.ext/edit/Main/Foo.

One of the problems is with $scriptUrlPath: I couldn't make it empty (""). I defined two additional variables in TWiki.cfg, by adding the following two lines:

$dispScriptUrlPath = "";
$dispViewPath = "";
The former is the script path which is shown in the links in the generated pages. The latter is the view script path in the generated pages. Setting them both to empty satisfies my requisites, while setting them to $scriptUrlPath and "/view" reverts to the classical behaviour.

I also changed TWiki.pm to use the new variables, with a couple substitutions (replace $scriptUrlPath with $dispScriptUrlPath and /view with $dispViewPath almost everywhere) and a condition where the view script can be either view or viewauth. See https://twiki.org/p/pub/Codev/ShorterURLs/ShorterUrlsPatchAB1.diff for the differences.

As to apache settings, I have the following .htaccess in the doc root:

RewriteEngine on

# Static files are served as usual
RewriteCond /home/antonio/wml/twiki/htdocs%{REQUEST_URI} -f
RewriteRule . - [L]

# uri's of the form /script/... are passed to the right script
RewriteCond %{REQUEST_URI} ^\/([^\/]*)(.*)$
RewriteCond /home/antonio/wml/twiki/cgi-bin/%1 -f
RewriteRule .* /cgi-bin%{REQUEST_URI} [PT]

# Existing documents are viewed
RewriteCond /home/antonio/wml/twiki/data%{REQUEST_URI}.txt -f [OR]
RewriteCond /home/antonio/wml/twiki/data%{REQUEST_URI} -d
RewriteRule ^.*$ /cgi-bin/view%{REQUEST_URI}

This setting seems to achieve what I wanted without losing functionalities and leaving the possibility to revert to the standard behaviour, but I haven't carried out extensive testing, so there might be bugs lurking.

-- AntonioBellezza - 27 Feb 2004

The whole scheme will of course be much slower since .htaccess-based URL rewriting requires re-jumpstarting the engine everytime you modify anything.

If you're putting things in .htaccess, I assume that means you don't have control over the server. URL rewriting isn't always allowed by admins. Most annoying, even if it is turned on, the default configuration doesn't allow you to turn on logging in an .htaccess file (since it's a huge performance hit), so you wind up doing all your debugging totally blind. You'd definitely want to develop on a machine that you controlled and then port the system over. Rewrite rules can be exceptionally tricky.

-- RobNapier - 30 May 2002

I tried to look for the file TWikiCfg.pm but could not find it, did you mean lib/TWiki.cfg? In there I saw:

#                   %SCRIPTURLPATH% : cgi-bin path of TWiki URL:
$scriptUrlPath    = "/twiki/bin";

And changed the second line to

$scriptUrlPath    = "";

But it did not seem to work. I also made the suggested changesd to httpd.conf and restarted the http deamon.

From the example above I changed these lines

RewriteCond /home/rnapier/public_html/twiki/data%{REQUEST_FILENAME}.txt -f [OR]
RewriteCond /home/rnapier/public_html/twiki/data%{REQUEST_FILENAME} -d
RewriteCond /home/rnapier/public_html/twiki/bin/%1 -f

into

RewriteCond /home/httpd/twiki/data%{REQUEST_FILENAME}.txt -f [OR]
RewriteCond /home/httpd/twiki/data%{REQUEST_FILENAME} -d
RewriteCond /home/httpd/twiki/bin/%1 -f

What am I missing to make it work? I like the idea of shorter URL's and would really like to implement it.

-- JakobTrier - 17 Jun 2002

This works fine for me on .htaccess but I would rather that Urls pointing to existing webs yet not existing topics would take me to create that topic rather than fail the test for existance and then say that a real file with that URL does not exist.

-- MartinCleaver - 09 Nov 2004

Alternatives

Alternative to URL rewriting (WoutMertens)

If you don't want to enable the rewrite engine (for efficiency reasons of course), this works just as well:

 Alias /twiki/bin "/local/twiki/bin"
 Alias /twiki/pub "/local/twiki/pub"
 Alias /twiki "/local/twiki/bin/view"

To make sure all the links TWiki serves up are also short, you need to add the following in lib/LocalSite.cfg (you can't do this with the configure script):

$TWiki::cfg{ScriptUrlPaths}{view} = '';

Advantages (apart from the short URLs):

  • No url rewrite engine needed
  • Only bin and pub are visible, no other directories are served. You don't accidentally leak files.

BTW, if you force authentication on viewing and therefore viewauth is the same as view, you can add

$TWiki::cfg{ScriptUrlPaths}{viewauth} = '';
as well.

-- WoutMertens - 07 Aug 2002 - updated 23 Nov 2006

BTW: if you "hardwire" the redirections into httpd.conf, there is no noticeable impact, e.g.:

    ScriptAlias /go "/usr/local/twiki/bin/go"
    ScriptAlias /Main "/usr/local/twiki/bin/view/Main"
    ScriptAlias /TWiki "/usr/local/twiki/bin/view/TWiki"

A lazy work-around to Wout's patch is to insert a rule in the DefaultPlugin. The server has to work harder, though:

sub endRenderingHandler
{
    $_[0] =~ s|$TWiki::scriptUrlPath/view/|/|go; # force relative URLs for view
}

Sooo: what is the status of fixing getViewUrl()? Will it be in the BeijingRelease?

-- PeterKlausner - 04 Nov 2002

Alternative: a redirect script

Because I am not the webmaster I can't play with rewrite rules; I can get the webmaster to give me one alias, but don't want to have too many, and don't want the webmaster to have to update aliases whenever someone creates a new wiki web.

So, here's where I am headed - coded this last Friday night, dry run testing it this week - one alias, http://OURSERVER/wiki to a cgi script "redirect.pl". This script looks at the URL, and figures out which is the wiki CGI script (such as view, edit), which is the wiki web, and which parts are artifacts of my installation's security model, such as "public" or "controlled". Or, more importantly, when such parts are not in the URL, it figures out defaults (e.g. by looking at the group ownership of a directory).

The script then rewrites the RL, and "redirects".

I've quoted "redirect", because I don't like traditional redirects: the URL the user sees is changed. Aliases would be nice because they don't change the user URL, but as I expplained above, I cannot use aliases easily.

My current BKM (Best Known Method) is to use a, gasp, frame: the redirect script creates a frameset with only one frame, the "expanded" URL that is being redirected to. To force clicking in the frame to change the URL of the frameset, I set <base ... target ="_top">

I know people hate frames. So far as I understand it, it is because frames had many brokennesses in early browsers. Anyway, if anyone can point me to a non-frames solution, I'd appreciate it.

Oh, yeah: twiki's configuration variables use the shorter URLs.

-- AndyGlew - 11 Aug 2003

Can we get this used on TWiki.org?

-- MartinCleaver - 07 May 2004

I am reluctant to enable this on TWIki.org since CoolURIsDontChange and a double set of links is confusing.

-- PeterThoeny - 07 May 2004

Peter:

  1. you already have a double set: these pages can be accessed via twiki.sf.net
  2. we should avoid URLs being expired, but this does not do that: it supports both. It also is a significant aid to getting people to understand the Area/Topic page naming convention.
  3. You can support the old ones... simply redirect to the new location.

-- MartinCleaver - 08 May 2004

Another idea:

Use ONE script that acts as a "controller" that forwards actions to other scripts. If no actions are specified in the URL, then the script assumes the action is to "view" the page. Example URL's using this method:

Aliasing can be done on the web server to point "/twiki" to the right script. This is a simple solution and provides nice URL's.

In any case, the current URL system is frustrating and should be changed. I read the contents of CoolURIsDontChange, and this is an argument I found in it:

2. URI's that have a good 'structure': no cgi-bin in the name or /index.html or even .html as extension. As Tim Berners-Lee puts it: Look for "cgi", "exec" and other give-away "look what software we are using" bits in URIs. Anyone want to commit to using perl cgi scripts all their lives? Nope? Cut out the .pl. Read the server manual on how to do it.

TWiki's current setup requires "bin" to be in the URL unless it is aliased out. This violates Tim's "rule".

Another implication of CoolURIsDontChange is that if you are going to change a URI, you should change it as soon as possible. Waiting longer just means more broken links.

-- KevinCraft - 27 Jun 2006

Sure, see (and please support) the CommonFrontEndCgiScript

-- MartinCleaver - 28 Jun 2006

I checked out CommonFrontEndCgiScript, and I don't see what it helps us to gain with regards to shorter URL's. A TWikiVerb still has to be present in all of the URL's. Since ~99% of all requests are for the "view" script, I don't see why it is necessary to include it in every URL--it should be assumed. The trend of the CommonFrontEndCgiScript seems to be headed toward keeping the TWikiVerb positioned before the Path/To/Topic in the URL. This means there will be no simple way of getting rid of the "view" element.

-- KevinCraft - 28 Jun 2006

Debugging

  1. Do you have RewriteEngine turned on?
  2. try running with the debugging logs:

RewriteLog logs/rewrite_log
RewriteLogLevel 9

Do not run this for a long period of time or on a heavily used server. If you get a lot of traffic, at least turn RewriteLogLevel down to 3 or the like. Otherwise you'll get a huge log (and the RewriteLog engine adds a lot of overhead so you'll see a significant performance hit). This will at least give you an idea of what's going on.

  1. Look at ShorterCaseInsensitiveURLs. It handles all of this a different way that may work better for you (and adds case insensitivity to the URLs to boot, which is what I'm running now on my site).

-- RobNapier - 18 Jun 2002

More instructions on how to use this.

I am not all to familiar with webservers, and couldn't get it to work. Documentation anyone?

-- ArthurClemens - 08 May 2004

Arthur: I'm not sure what you could be having a problem with. Is it the .htaccess file or the TWikiDotCfg file?

Might be easier if we chat. Either messenger or TWikiIRC might be the best way to do this.

-- MartinCleaver - 08 May 2004

I created a new .htaccess file in the root directory. Perhaps more complicated, I am on DreamHost, and am on one server with 2 virtual domains. So in TWikiDotCfg I have $homeDir = "/home/aclemens/dekko.nl/twiki"; while the site domain is www.dekko.nl. The directory where I placed the new htaccess was in /home/aclemens/dekko.nl. I put in above code, with paths changed. I believe I need to do:

RewriteCond /home/aclemens/dekko.nl/cgi-bin/projects%1 -f
RewriteRule .* /cgi-bin/projects%{REQUEST_URI} [PT]

But as soon as I did this, the whole twiki site broke. And stayed broke until I deleted the new htaccess file, uploaded new bin files and the old htaccess file in bin. One thing I am thinking of: what permissions should a htaccess file have?

-- ArthurClemens - 09 May 2004

Please describe "broke"

-- MartinCleaver - 09 May 2004

- I got an Internal Server Error -- ArthurClemens - 09 May 2004 - 02:55

- Ok, and was there a message in the apache error log? -- MartinCleaver - 09 May 2004 - 04:04

- incidently, permissions: a+r would be sufficient on your .htaccess files -- MartinCleaver - 09 May 2004 - 04:05

Couldn't find this first, but now I see this is informative smile I got this:

[alert] /home/aclemens/dekko.nl/cgi-bin/projects/.htaccess: Invalid command 'scripts', perhaps mis-spelled or defined by a module not included in the server configuration

[error] (13)Permission denied: Can't open directory for index: /home/aclemens/dekko.nl/cgi-bin/

Additional question (food for FAQ): where do I put this .htaccess file? Separate, or in the bin .htaccess?

-- ArthurClemens - 09 May 2004

- ok. (1) indicates that you have a command "scripts" in /home/aclemens/dekko.nl/cgi-bin/projects/.htaccess: this is not listed above so I don't know where you got that.

(2) indicates that the path down to /home/aclemens/dekko.nl/cgi-bin/ is not executable by the webserver. Often this is because it runs as a different user until it gets to your directory at which point it does an "su" to you.

(3) is that all .htaccess files are read, so it does not matter. For cleanness have the one with the redirects in the top level.
-- MartinCleaver - 09 May 2004 - 14:34

I don't know if this is the cause of your problem, but I did discover that on Apache 2.0.49 on Gentoo Linux, the filesystem pathnames used in the RewriteRule attributes in the httpd.conf file (at the top of this page), are absolute, not a relative URL pathname as this page has. Meaning I had to put "RewriteRule ^(.*)$ /var/www/twiki/bin/viewauth$1" instead of the relative "RewriteRule ^(.*)$ /twiki/bin/viewauth$1". Otherwise I was getting error 403's in the browser.

-- AdamTheo - 10 May 2004

To Do

Many templates need updating - both in Core and in Skins

I have the latest beta where SCRIPTURLPATH gets replaced by $dispScriptUrlPath instead. Suggests one variable (SCRIPTURLPATH) but uses something else instead ($dispScriptUrlPath) -- quite confusing.

According to TWiki.cfg comments $dispViewPath is supposed to be used instead of /view, but default templates still have the latter hardcoded in many places. (Nothing a little perlpie wouldn't cure, but still...)

-- TommiKomulainen - 10 Jul 2004 - 15:17


ZWiki has already implemented shorter urls.

If you have difficulty doing it with TWiki, try installing ZWiki instead and see if that works better. ZWiki is writen in Python.

http://www.zwiki.org

-- RogerChrisman - 18 Nov 2003

Dakar specific issues

The current Dakar code prevents most of the above described setups to work, since dispViewPath has disappeared ; two bugs related to this topic's issue have been filled :

That's why I just changed this topic's classification to BugReport, brought ImplProgress back to 0% and SpecProgress to 50%.

-- BenVoui - 09 Nov 2005

Other Gotchas

Here is what I added to my httpd.conf file:

# ----- Below added by JAT on 2002.06.17
RewriteEngine on
# ----- Below added by JAT on 2002.06.19
RewriteLog logs/rewrite_log
RewriteLogLevel 9
# ----- End of JAT addition 2002.06.19

# If we used a topic or web name, rewrite it into viewauth
RewriteCond %{REQUEST_FILENAME} !/twiki/
RewriteCond /home/httpd/twiki/data%{REQUEST_FILENAME}.txt -f [OR]
RewriteCond /home/httpd/twiki/data%{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ /twiki/bin/viewauth$1

# If we used a script name, rewrite it into twiki/bin
RewriteCond %{REQUEST_FILENAME} !/twiki/
RewriteCond %{REQUEST_FILENAME} ^/([^/]+)/
RewriteCond /home/httpd/twiki/bin/%1 -f
RewriteRule ^/[^/]+/(.*)$ /twiki/bin/%1/$1 [PT]
# ----- End of JAT addition 2002.06.17

I tried to hit http://mda/twiki/bin/view/Main/WebHome twice and I just got no page at all, as if it did not exist. [IP address changed from original file to 1.1.1.1]

1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) init rewrite engine with requested uri /
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^(.*)$' to uri '/'
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/' pattern='!/twiki/' => matched
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/.txt' pattern='-f' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/' pattern='-d' => matched
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) rewrite / -> /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^/[^/]+/(.*)$' to uri '/twiki/bin/viewauth/'
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/twiki/bin/viewauth/' pattern='!/twiki/' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) local path result: /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) prefixed with document_root to /var/www/html/twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:11 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (1) go-ahead with /var/www/html/twiki/bin/viewauth/ [OK]
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) init rewrite engine with requested uri /
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^(.*)$' to uri '/'
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/' pattern='!/twiki/' => matched
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/.txt' pattern='-f' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/' pattern='-d' => matched
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) rewrite / -> /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^/[^/]+/(.*)$' to uri '/twiki/bin/viewauth/'
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/twiki/bin/viewauth/' pattern='!/twiki/' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) local path result: /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) prefixed with document_root to /var/www/html/twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:48 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (1) go-ahead with /var/www/html/twiki/bin/viewauth/ [OK]
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) init rewrite engine with requested uri /
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^(.*)$' to uri '/'
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/' pattern='!/twiki/' => matched
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/.txt' pattern='-f' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/' pattern='-d' => matched
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) rewrite / -> /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^/[^/]+/(.*)$' to uri '/twiki/bin/viewauth/'
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/twiki/bin/viewauth/' pattern='!/twiki/' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) local path result: /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) prefixed with document_root to /var/www/html/twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:51 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (1) go-ahead with /var/www/html/twiki/bin/viewauth/ [OK]
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) init rewrite engine with requested uri /
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^(.*)$' to uri '/'
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/' pattern='!/twiki/' => matched
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/.txt' pattern='-f' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/home/httpd/twiki/data/' pattern='-d' => matched
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) rewrite / -> /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (3) applying pattern '^/[^/]+/(.*)$' to uri '/twiki/bin/viewauth/'
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (4) RewriteCond: input='/twiki/bin/viewauth/' pattern='!/twiki/' => not-matched
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) local path result: /twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (2) prefixed with document_root to /var/www/html/twiki/bin/viewauth/
1.1.1.1 - - [19/Jun/2002:15:03:52 +0900] [SMDAJPTYO001/sid#809e190][rid#813acf0/initial] (1) go-ahead with /var/www/html/twiki/bin/viewauth/ [OK]

So I changed it back and it worked again.

Does it give you any idea what migyht be wrong?

Ah, something springs into my eyes, I see in the last line it says " go-ahead with /var/www/html/twiki/bin/viewauth/ " the files is not in /var/www/html/twiki/ but in /home/httpd/twiki/

Do you know where this information can be changed?

-- JakobTrier - 26 Jun 2002

I would assume this means that apache itself is misconfigured. "/var/www/html" is going to come from the httpd.conf files. What is DocumentRoot set to in your apache configs?

-- RobNapier - 26 Jun 2002

You are right, twice in httpd.conf did I find "/var/www/html". First after the line "# Documents" later after "# General setup for the virtual host". Should I change both to /home/httpd/twiki where twiki resides? Or is it only one of them that needs to be changed.. Hmm, I better RTFM smile

Random Comments:

  1. Not everyone will want to install twiki as the root set of pages on the web server. If you don't, then twiki will have a root - either in a cgi-bin directory, or something like /twiki.
  2. The "bin" part could be dropped if the /pub directory is separately configured to serve pages out. But that way you have /twiki and /pub on root. No real difference from /twiki/pub, and in the former case means that anyone who runs a /pub on the root of the server (see 1) will have to share TWiki's pub.
  3. Shorter URLs can be achieved by precompiling/publishing web pages into a directory that is in turn the docroot for the server. (As I do for our local community website, as well as the TWiki at work, and a personal website - not the one linked to from here)

Putting suffices of the scripts is a windows anacronism - there is no need for it. File identification type based on file extension is a flawed mechanism with well known security issues. Leaving out the extension is one area where twiki currently does the right thing and doesn't have to follow instructions on how to remove them. Pages not having extensions (eg .html) is one thing it gets "right".

Things TWiki gets wrong are:

  • Have "tool" related things in the URL. (twiki/bin) In installations where TWiki isn't in the root of the server this is justifiable
  • Name pages based on classification and topic. (Erm, oops!) It's better to have pages which are date.topic. TWiki's current URL system is essentially a search of that namespace .

That said, even the second point here can be justified if pages aren't renamed but can be referenced/accessed in different ways without changing the original URL.

-- MichaelSparks - 24 Jun 2003

Mostly I agree with you Micheal. However on the web, outside of weird places like wikis, everything is done by 'viewing'. Therefore including the action 'view' in the URL is redundant. It is only necessary to specify the action if it is something other than the default, IMO.

On web servers which do more things than twiki, then 'twiki' becomes a necessary URL component. 'bin' however is not necessary.

-- MattWilkie - 24 Jun 2003

Issue: urls like http://example.com///Webname/WebHome

Occasionally I find I end up with URLs such as the one above, which are annoyingly untidy.

Once I've saw the browser try to connect to a machine called Webname, but I have been unable to reproduce this since.

-- MartinCleaver - 10 Jan 2005

A faster and simpler solution?

I've been implementing autonomously a solution for short URLs that ended up (in my opinion) being simpler and faster to develop.

You can find it in ShorteningUrls

Limits:

  • it assumes that all scripts start with lowercase letters (which is true so far) and that all Webs start with an uppercase letter (which is also true, I guess, at least in most implementations).
  • it requires a modification in UI::View.pm for viewauth scripts to work. I haven't tested it extensively, which is why it is posted to the Support Web instead of the Codev Web.

I would appreciate comments.

-- FabioVitali - 10 Feb 2005

A similar, ready-to-use solution is explained on http://wiki.boum.org/TechStdOut/BoumTWikiSetup ; it integrates the Apache RewriteRules, TWiki patches/config and Perl substitutions needed to get :

  • shorter URLs : not only you can use them, but TWiki generates such nice URLs ;
  • httpS-only authentification.

-- BenVoui - 07 Apr 2005

This topic was part of the CairoRelease, it's pointed to from TWikiHistory as a feature of that release. So for documentation purposes the form must remain the same. If there are issues with current or future releases they will have to be managed in separate topics.

-- SamHasler - 29 Apr 2006

See also ConsolidateShorterURLs.

-- StephaneLenclud - 03 Mar 2007

I have found out, that searching for documents in twiki.org is nearly impossible through Google. We seem to have a very bad ranking and indexing with Google. We should try to change that.

-- MartinSeibert - 23 May 2008

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatpatch GoUndefined-20041122.patch r1 manage 1.1 K 2004-11-22 - 16:04 UnknownUser Fix Apache2/Redirect + Go/Jump to undefined topic
Unknown file formatdiff ShorterUrlsPatchAB1.diff r2 r1 manage 3.2 K 2004-02-28 - 15:37 UnknownUser Patch by Antonio Bellezza, rev.1
Edit | Attach | Watch | Print version | History: r86 < r85 < r84 < r83 < r82 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r86 - 2008-05-23 - MartinSeibert
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.