301 redirect and 404 not found handler for Textpattern articles. Redirects browsers and search engine spiders to the correct article URL after a title or section change, and displays a 404 response for articles that don’t exist.
Textpattern articles are currently reachable via several different URL paths. For example:
External factors can multiply these (e.g. www.example.com vs. example.com).
This can cause problems with search engines and link aggregators, since they don’t have any way of knowing that all of these URLs represent the same page (as opposed to multiple pages with identical content).
txp:zem_redirect is designed to help reduce the problem a bit. It checks the URL used to fetch each article; if it doesn’t match the correct URL for the article (including the article-title and full hostname as specified in the Textpattern config), it’ll return a 301 Moved Permanently response to direct the user’s browser to the correct URL. It also works as a 404 handler for articles that don’t exist or are not visible.
Just plonk the tag at the top of your article page, and it’ll do the rest. It must be the very first tag on the page, before the doctype. It has no effect in messy URL mode, or on pages other than individual articles.
warning – if you’re already using URL rewriting or other clever redirection, there’s a chance this could cause circular redirects. Test carefully, and don’t say I didn’t warn ye.