Redirecting Radio UserLand URLs with PHP

This weblog uses Python Community Server (PyCS), an open-source version of the Radio Community Server, to host visitor comments and trackback links. It's a reliable service that adds a few new features beyond the ones offered by UserLand's comment server: Comment deletion, RSS feeds for every discussion, and the ability to download all of your comments as a single file in RSS 2.0 format.

If you inspect the comment and trackback links on this site, you'll see that they appear to be hosted here on rather than on

I'm doing this with two simple PHP scripts that redirect the URLs to the correct PyCS URLs.

I implemented this feature so that I can take comment and trackback links offline when PyCS experiences an outage.

During a comment/trackback server outage, Workbench (and presumably most Radio weblogs) won't display a weblog page until the server request times out with an error -- a delay of 60 seconds or more. Most visitors conclude the site itself is offline and give up, causing traffic to slow to a trickle.

Now during an outage, I can replace the redirection scripts with "comments offline" and "trackbacks offline" text.

Here's the PHP script to redirect comments:

$url = str_replace("128729", "0000001", $REQUEST_URI);
$url = str_replace("/workbench/php/comments.php", "/system/", $url);
header("Location:".$url); exit;

This script does three things to the requested URL, which PHP makes available in a $REQUEST_URI variable:

  1. Change my Radio user number (128729) to my PyCS user number (0000001).
  2. Change my redirection URL on, /workbench/php/comments.php, to the real URL on PyCS, /system/
  3. Redirect the browser to the real URL on PyCS.

For example: Here are links to an original URL and a redirected URL.

The same technique is used in a trackback redirection PHP script:

$url = str_replace("128729", "0000001", $REQUEST_URI);
$url = str_replace("/workbench/php/trackback.php", "/system/", $url);

The scripts are stored in a php folder inside Radio's www folder. When there's an outage, I move the scripts and create new versions of the files with nothing but text like this:

Comments offline

There's probably a way to accomplish this in Apache with .htaccess files and mod_rewrite, but PHP made it too easy to look elsewhere.

Add a Comment

All comments are moderated before publication. These HTML tags are permitted: <p>, <b>, <i>, <a>, and <blockquote>. This site is protected by reCAPTCHA (for which the Google Privacy Policy and Terms of Service apply).