|
|||||
|
|||||
|
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 - http://dave.editthispage.com/, 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 recordThe 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:
Step 2: Tell Apache where things areNow 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 foo.yourdomain.com and turning the foo bit into a path, e.g. yourdomain.com/foo. Make a <VirtualHost> block for yourdomain.com:
Now the rewriting: add the following after ServerName:
This proxies http://yourdomain.com/* through to http://127.0.0.1:5445/* (this connects to the local PyCS that's running on port 5445). Now the user sites:
Now cross your fingers and restart Apache:
Now go to system.yourdomain.com/updates.py and see if you get the updates page. If you do, it worked! Now make some symlinks to get some aliases going.
Now go to foo.yourdomain.com and see if you get what used to be www.yourdomain.com/users/0000001. If you do, good! Step 3: Tell PyCS where things should goRadio 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 http://www.yourdomain.com/users/*. 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:
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 redirectionWhenever 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:
This will point everyone in the right direction. ProblemsIt's not perfect - I still haven't got it redirecting properly within sites. If you go to http://notes.pycs.net/stories, for example, it won't work because PyCS tries to redirect you to http://notes.pycs.net/notes/stories/ instead of http://notes.pycs.net/stories/. <sigh> More later, when I've fixed that. |