(redirected from WikiSuggestions/ScriptName)

[Home]ScriptName

UseModWiki | RecentChanges | Preferences

$ScriptName is a global variable that is assigned the name of the calling script ( as you would have guessed ;-) ) in the InitRequest function. It's used in a few places to build URLs that are used in links etc.

A typical URL to a Wiki is http://www.example.com/cgi-bin/wiki.pl, and in that case $ScriptName is assigned the value 'wiki.pl'.


Problem

I for one prefer short URLs, and it isn't exactly a natural law that the script name appears in the URL. Applied to the above example URL, and assuming Apache, I can put an .htaccess file in the document root with this directive:
 DirectoryIndex cgi-bin/wiki.pl index.html
Doing so will allow me to run the script through the URL http://www.example.com/.
However, all the generated links will point to http://www.example.com/wiki.pl?[something] , and if I click such a link, the server will tell me that the "URL /wiki.pl was not found on this server" or the like.

Simple solution

If the assignment of $ScriptName is made conditional, i.e. if this line (line 428 in version 1.0.4):
 $ScriptName = pop(@ScriptPath);
is exchanged for
 $ScriptName ||= pop(@ScriptPath);
I can simply say
 $ScriptName = '/';
in the config file (or in a wrapper script), and the shorter URL http://www.example.com/ will work just fine.

Another thing is that the variable name then ought to be $ScriptURL rather than $ScriptName... --GunnarH

I vaguely remember to ran into something similar when adopting usemod (or maybe oddmuse) to work with url rewrite a few years ago. Your entry in .htaccess looks a bit strange to me. -- MarkusLude


UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited May 25, 2009 10:33 pm by MarkusLude (diff)
Search: