Recipes
Apache RedirectMatch
If you used to run WordPress and imported your old blog into Zine you now need to make sure your old URLs are still available, yet, redirected to the new ones.
If you served your old blog like:
http://blog.domain.tld/index.php/2008/01/01/my-blog-post/
The new URL will be:
http://blog.domain.tld/2008/01/01/my-blog-post
If you run apache you can make use of RedirectMatch to redirect your old URL's to the new ones.
Add to your vhost configuration the following lines:
RedirectMatch permanent ^/index.php(.*)([/]+)$ $1 RedirectMatch permanent ^/index.php(.*)$ $1
The first rule, will permanently redirect the URL's that contain the last / in the url, the second will permanently redirect those that do not contain the last /. I was unable to make that in a single rule, the redirects didn't seemed to work.
The last thing is to redirect the old uploads path to the new one:
RedirectMatch permanent ^/wp-content/uploads/(.*)/(.*)/(.*)$ /_uploads/$3
This will redirect:
http://domain.tld/wp-content/uploads/2007/05/example.uploaded.picture.png
to:
http://domain.tld/_uploads/example.uploaded.picture.png
Of course you'll have to re-upload your old blog uploads to the new one and keep the same names.
Dynamic subdomains
Here's a VirtualHost setup to use dynamic subdomains. Each subdomain uses its correspondent instance folder. For this setup, I disabled Zine's websetup, or any requested subdomain would potentially start a new instance setup - and I want to set them manually.
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias *.domain.com
ServerAdmin webmaster@domain.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([a-z0-9_-]+)\.domain\.com$ [NC]
RewriteRule .* - [E=zine.instance_folder:/var/www/domain.com/instances/%1]
WSGIScriptAlias / /path/to/zine/zine.wsgi
<Directory "/path/to/zine">
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/domain.com-error_log
</VirtualHost>
Zine and lighttpd
Just follow the installation guide at http://dev.pocoo.org/projects/zine/browser/INSTALL till step 3. Instead of zine.wsgi use zine.fcgi.
Edit your lighttpd.conf file (/etc/lighttpd/lighttpd.conf).
$HTTP["host"] =~ "(^|www\.)yourblog\.com$" {
fastcgi.server = ("" =>
((
"bin-path" => "/var/zine/yourblog/zine.fcgi",
"socket" => "/tmp/fcgi-zine.socket",
"check-local" => "disable"
))
)
}
This would run yourblog at the root of yourblog.com. Make sure the lighttpd-user has read and write access to these directories.
In my case zine throwed errors about PYTHON_EGG_CACHE. Just add a "bin-environment" => ("PYTHON_EGG_CACHE" => "/path/to/python/egg/cache") into the fastcgi-config. The lighttpd user needs read and write access to this directory too.
Seperate secure admin-area with lighttpd
Sometimes it's a really bad idea to log into your blog over unsecure connections. Fortunately Zine makes it really easy to setup another instance of the same blog to be accessible over https because most of the links Zine produces are relative (unlike absolute links that would bring you to your unsecure Zine-installation).
Here is how I did it: This is my configuration for the secure Zine-instance:
$SERVER["socket"] == "123.456.789.012:443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/certs/cert.pem"
ssl.ca-file = "/etc/certs/cert.crt"
server.document-root = "/htdocs/something/"
$HTTP["host"] =~ "(^|www\.)yourblog\.secureurl\.com$" {
fastcgi.server = ("" =>
((
"bin-path" => "/var/zine/yourblog/zine.fcgi",
"socket" => "/tmp/fcgi-zinesecure.socket",
"check-local" => "disable",
"max-procs" => 1,
"bin-environment" =>
("PYTHON_EGG_CACHE" => "/path/to/python/egg/cache")
))
)
}
}
The configuration for the unsecure host links to the same zine.fcgi script. I disallow access to the /admin-path to prevent accidental logins over the unsecure host:
$HTTP["host"] =~ "(^|www\.)yourblog\.com$" {
fastcgi.server = ("" =>
((
"bin-path" => "/var/zine/yourblog/zine.fcgi",
"socket" => "/tmp/fcgi-zine.socket",
"check-local" => "disable",
"bin-environment" =>
("PYTHON_EGG_CACHE" => "/path/to/python/egg/cache")
))
)
$HTTP["url"] =~ "^/admin" {
url.access-deny = ( "" )
}
}
It's kind of ugly, because Zine still produces absolute links to your unsecure blog. The admin-interface still works fine, except: you cannot show previews of your not-yet-published posts. You could use an extra zine.fcgi-script with another instance-folder (and another zine.ini with the URL to the secure instance), but you wouldn't be able to configure your (non-secure) blog anymore (you would need to copy the zine.ini of your secure blog to the instance-folder of your unsecure blog after you have changed templates or installed plugins).