Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

CustomRedirects

Summary: This recipe modifies the behavior of PmWiki's redirect markup
Version: v1.0.0
Prerequisites: PmWiki v2.1.0, possibly earlier
Status: Stable
Maintainer: Ryan Varick
Categories:

Question

Is it possible to modify the behavior of PmWiki's redirect markup?

Answer

Yes! The redirect markup is actually quite interesting. Using the option status= parameter, PmWiki can send browsers the appropriate HTTP status code:

  • 301 = moved permanently
  • 302 = found
  • 303 = see other
  • 307 = temporary redirect

Usually, authors will want to use either 301 or 307. For convenience, PmWiki appends ?from=Page.Name to the URL, which is used by the new page to display the redirect message. Sometimes though, this is not the desired behavior. For permanently moved pages (those using status=301), the new page will always have the query string attached as part of its permanent name. Search engines crawling the site may add new pages with this query string.

This recipe prevents PmWiki from appending anything to the URL when a 301 status code is requested. As a side effect, this recipe groups relevant redirect code into a single file, making it easy to further customize the behavior of redirect.

Installation

First, download redirect.phpΔ to your cookbook directory. Now add the following line to local.php:

include_once('cookbook/redirect.php');

You're done!

To omit query strings on redirects, use:

(:redirect New.Page status=301:)

Notes

See Also

RedirectSilent RedirectIntermap

Comments

Edit - History - Print - Recent Changes - Search
Page last modified on February 13, 2008, at 06:23 AM