[pmwiki-users] :SPAM: Get Rid of Main

Eemeli Aro eemeli at gmail.com
Tue Jun 30 05:13:31 CDT 2009

2009/6/30 Tim E. Rhodes <trhodes at trhodes.net>:
> Hello Everyone,
> Is anyone using: http://www.pmwiki.org/wiki/Cookbook/GetRidOfMain and can
> you help with an issue I’m having with it?
> I am using the section for use with Clean URLs (with PmWiki v2.21) and
> everything seems to work with the exception of links to non-existing pages
> in the Main/ group, i.e. [[NewPage]]. Instead of the 404 page not found
> page, the link simply opens Main/HomePage. If I preface the link with
> [[Main/NewPage]] for example, it opens the correct 404 page, but when you
> click the link to create the NewPage, it opens Main/HomePage for editing
> instead of Main/NewPage.

I was having similar issues with it and partly due to them came up
with an alternative.

I've reconfigured my group main pages to have URLs like /Site instead
of /Site/Site. This way you end up having more groups than if they
were all under Main/, but if it turns out you need to expand on
something you can just add to the pre-existing group.

Here's the relevant config stuff; this requires two parts (and assumes
that $EnablePathInfo is set):

First, set the value of {$PageUrl}. The following will also make the
Main.HomePage default URL be just the root of the wiki, eg.
http://example.com/wiki/ instead of

$FmtPV['$PageUrl'] = 'PUE(($pn=="Main.HomePage")
  ? "$ScriptUrl/"
  : ( ($name==$group)
    ? "$ScriptUrl/$group"
    : "$ScriptUrl/$group/$name" ))';

Second, we need to stop ResolvePageName from redirecting to eg.
/Site/Site every time we follow a link to /Site:

if ( strpbrk($pagename,'./') === FALSE ) {
  SDV($DefaultPage, "$DefaultGroup.$DefaultName");
  $p = MakePageName($DefaultPage, $pagename);
  if (PageExists($p)) $pagename = $p;

In fact you might be able to combine the above with a type of
GetRidOfMain by also adding the following to your config, try it and
see what happens:

$PagePathFmt[] = 'Main.$1';


More information about the pmwiki-users mailing list