[pmwiki-users] protection against reading directories with truncated path
Patrick R. Michaud
pmichaud at pobox.com
Wed Sep 14 11:03:31 CDT 2005
On Wed, Sep 14, 2005 at 05:31:42PM +0200, Stephan Schildberg wrote:
> >You can actually have PmWiki return a 404 for non-existent pages:
> >
> > if ($action == 'browse' && $pagename && !PageExists($pagename)) {
> > header("HTTP/1.0 404 Not Found");
> > print "Page Not Found\n";
> > exit();
> > }
> >
> This works fine (thank you Patrick!), how can I link to a custom error
> page, instead of the print command?
> The most elegant way of course would be a link to another pmwiki page
> for me.
Ah, if you're wanting to stay within PmWiki, the easy way to do this
is to use the $DefaultPageTextFmt variable. This variable contains
the markup text to be used when a non-existent page is requested.
So, to redirect to another pmwiki page, you can set:
$DefaultPageTextFmt = '(:redirect Main.NoSuchPage:)';
which will redirect requests for non-existent pages to Main.NoSuchPage.
Or, if you simply want to display the contents of Main.NoSuchPage
without the redirection, you can do:
$DefaultPageTextFmt = '(:include Main.NoSuchPage:)';
This causes the browser to remain at the non-existent url.
Or, if you just want to put the markup text directly into
$DefaultPageTextFmt, you can do that:
$DefaultPageTextFmt = 'Sorry, no such page.';
There are still other ways to do it, but these are among the easiest.
Pm
More information about the pmwiki-users
mailing list