http://mark.kolich.mobi/m.php?a=1
to this:
http://mark.kolich.mobi/m.php/1
This improvement was fairly easy to implement as I described here. However, I realized today that I wasn't totally satisfied with this enhancement, given that the ".php" in the URL was still visible. After a little investigation, I discovered that I could use Apache's mod_rewrite to make my mobile URL's look a little cleaner, like so:
http://mark.kolich.mobi/m/1
This URL style is much simpler and cleaner: I dropped the annoying query string, and I also got rid of the .php extension. Implementing this was actually quite easy using mod_rewrite. I simply used mod_rewrite to internally re-write any requests starting with "m" to the PHP script that serves up individual articles/posts on my mobile blog. In my Apache httpd.conf file, I added the following:
RewriteEngine On
RewriteRule ^/m /m.php [L]
RewriteRule ^/twitter /tw.php [L]
Any request starting with "m" will be sent to m.php. Any request starting with "twitter" will be sent to "tw.php". Check out my mobile blog to see this re-writing method in action. The PHP code that parses the REQUEST_URI to determine what article to serve up can be found here.
Simple enough. Enjoy.


Did you find this post helpful, or at least, interesting?