Removing www from Multi-sites or Subdomains in .htaccess

If you are running a Multisites or Subdomains sites this .htaccess RewriteRule code might come in handy specially for purpose of SEO. You can clean up your URL from http://www.yourdomain.com to http://yourdomain.com and remove the “www” with 301 redirect to non-www.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]

Charity Hack 2009

I have been extremely busy lately and I have totally neglected my blog over the last few months and I thought I would make a quick post.

A few weeks ago I participated on Charity Hack 2009 hosted by PayPal and sponsored by JustGiving and MissionFish with the aim to build an app in 24 hours over the weekend and overall after all hacks we won the second prize.

Convert Linux/Unix timestamp to human readable format in PHP

This functin will help to convert the Linux/Unix timestamp to human readable format:

<?php
function unix_timestamp_to_human ($timestamp ""$format 'D d M Y - H:i:s')
{
    if (empty(
$timestamp) || ! is_numeric($timestamp)) $timestamp time();
    return (
$timestamp) ? date($format$timestamp) : date($format$timestamp);
}

$unix_time "1251208071";

echo 
unix_timestamp_to_human($unix_time); //Return: Tue 25 Aug 2009 - 14:47:51 
?>

Microsoft Word Document HTML Cleanup in PHP


I had to cleanup a HTML created out of MS Word Document manually.  Honestly it is a pain to manually search and replace all the junks Word Document generating.  So I have written a text conversion function in PHP to automatically cleanup the MS Word junks and output HTML entities.

How to install YUM, Zend Optimizer, eAccelerator and APC

Recently a friend had difficulty installing Alternative PHP Cache (APC) and upload progress for his Drupal CMS on Debian VPS. Therefore I tought of sharing this post about how to setup and run your virtual private server with most useful PHP packages.

I would assume you have a Debian VPS, CentOs or Ubuntu and you would like to install APC, Zend Optimizer and eAccelerator for the best PHP performances or if they are required by some third party applications.

I normally like to install everything on Debian, CentOs or Ubuntu using the yum (Yellow dog Updater, Modified) package manger to make sure that updates for all applications are uniform and its easy to do, easy to search for available packages and easier to type instead of apt-get.