Python Community Server (development progress)
Running commentary on the progress of the development of the Py-C-S; this blog gets updated when coding goes on. Here is some answers to questions that have come in.

Manila-style URLs in PyCS

If you've been to a site like EditThisPage and BlogSpot, you'll notice that every sub-site has its own domain -, for example.  Wouldn't it be cool if you could do that with PyCS?

Well, it seems that you can!  It's a bit of work to get going, but it's not impossible.

Step 1: Set up the DNS record

The first step is to register a domain and to set up DNS hosting.  Set up a wildcard A record (PyCS actually uses a CNAME, but that's a whole 'nother story) to point all subdomains to the same machine:

*    A

Step 2: Tell Apache where things are

Now go into your Apache config and fire up mod_rewrite.  What you're going to do here is cunningly avoid the necessity for loads and loads of <VirtualHost> blocks by rewriting and turning the foo bit into a path, e.g.

Make a <VirtualHost> block for

DocumentRoot /var/www/wherever
ServerAlias *

Now the rewriting: add the following after ServerName:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(.+)$1 [P]

This proxies* through to* (this connects to the local PyCS that's running on port 5445).  Now the user sites:

RewriteCond %{HTTP_HOST} ^[^.]$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)*)$1$2 [P]

Now cross your fingers and restart Apache:

apachectl restart

Now go to and see if you get the updates page.  If you do, it worked!  Now make some symlinks to get some aliases going.

ln -s users/0000001 foo

Now go to and see if you get what used to be  If you do, good!

Step 3: Tell PyCS where things should go

Radio and xmlStorageSystem (and thus PyCS) work together to figure out URLs for files.  When Radio sends a file to a community server, the community server sends back the absolute URL for the file.  This lets Radio make links to that file from anywhere, safe in the knowledge that they actually will work.

However, at this point, PyCS is still telling your users' Radios that their blogs are at*.  You don't want this!  You want them to go to the proper URLs!  PyCS can do this - just add some aliases into pycs.conf:


0000001 =

Note: you might need to update your PyCS before this will work.  Update from CVS on SourceForge or download the latest distro archive and unpack it over the top of your current PyCS files.

Now restart PyCS and tell your users to do a Radio -> Publish -> Entire Website.  They might need to do it twice, but it sometimes seems to work here on the first go.  Now all the auto-generated links will work.

Step 4: Put in some redirection

Whenever you change links, you should put in redirects to point people (and search engines) in the right direction.  Apache does this with the 'Redirect' command.  Put the following in the <VirtualHost> block for your old domain:

Redirect permanent /users/0000001

This will point everyone in the right direction.


It's not perfect - I still haven't got it redirecting properly within sites.  If you go to, for example, it won't work because PyCS tries to redirect you to instead of  <sigh>

More later, when I've fixed that.

© Copyright 2002 Phil at Myelin. Click here to send an email to the editor of this weblog.
Last update: 2002-04-30; 11:56:46 p.m..