CustomRedirects

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

Question

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

Answer

Note: PmWiki core's redirect markup now accepts the status=301 additional parameter.

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

Comments

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.