Since I’m not adverse to regular expressions, I’ve tidied up the addresses for my blog posts.
Now, rather than an address that looks like “http://blog.ben-ward.co.uk/index.php/2004/01/05/”, it looks like “http://blog.ben-ward.co.uk/archive/2004/01/05/”. Small change, but important because “index.php” means nothing, but “archives” (a naming convention that I’ve stolen from the rather popular Wordpress) does. The URL now bears some relation to accessing one of my historical blog posts.
With that small success in the bag, I’ve also smoothed out access to my XML feeds. The four XML syndication formats that b2Evolution provides (RSS, RSS 2, RDF and ATOM) can now be accessed via “http://blog.ben-ward.co.uk/read/rss”, “/read/rss2” for RSS version 2.0, “/read/rdf” for RDF format and “/read/atom” for an ATOM 0.3 feed.
Techie “HOWTO” bit…
Ultimately, this is user-friendly polish of the highest order and takes some of the pain out of the “one file to rule them all” nature of PHP programming.
You can achieve the same results (in b2Evolution) using the following Apache mod_rewrite rules. There’s still a lot of investigation that I need to do, not least because b2Evo does some URL rewriting of its own separately. That seems to be preventing me getting friendly-urls for my sub-blogs (my bookmarks list, for example).
- “index.php” to “archive”
# Add this to your .htaccess file # URL Rewriting for user-friendliness RewriteEngine On RewriteBase / # Use "archive" rather than "index.php" RewriteRule ^/?archive(\.php)?(.*)$ /index.php$2
Once this rule is in place, test it (go to “http://www.yourblog.com/archive” and see if it goes to your homepage).
To get b2Evo to use this in the URLs that it generates, go into the preferences for your main Blog and set its ‘Stub Name’ to “archive” and choose the ‘Preferred access type’ as ‘Other blog through stub file’. Presto.
(\.php)part of the above rule is a hack that prevents b2Evo breaking in places where it generates links with a .php extension (so generates “archive.php”). It’s not wonderfully pretty but it’s easier than modifying an unlimited quantity of b2Evolution’s source code.
- XML Feed access
These ones don’t need any changes afterwards (note that they’re hard coded to my main blog (the number 2). I’ve made the choice that I’ll have to set up more rules for any other blogs that I want feeds for.
# XML Syndication Rewrites RewriteRule ^/?xml/rss/?$ /xmlsrv/rss.php\?blog=2 RewriteRule ^/?xml/rss2/?$ /xmlsrv/rss2.php\?blog=2 RewriteRule ^/?xml/atom/?$ /xmlsrv/atom.php\?blog=2 RewriteRule ^/?xml/rdf/?$ /xmlsrv/rdf.php\?blog=2 RewriteRule ^/?read/rss/?$ /xmlsrv/rss.php\?blog=2 RewriteRule ^/?read/rss2/?$ /xmlsrv/rss2.php\?blog=2 RewriteRule ^/?read/atom/?$ /xmlsrv/atom.php\?blog=2 RewriteRule ^/?read/rdf/?$ /xmlsrv/rdf.php\?blog=2
As well as “/read/”, my feeds are also accessible through “/xml/”, for nerdier visitors.
Expect an update if/when I figure out how to get the bookmarks blog link working.