Personal website of Sufi Nawaz

Forwarding from non-www to www domain using URL rewrite rules in Apache (){

Problem Description:
With the installation of WordPress multisite network in my site, entering the URL http://sufinawaz.com took me to the signup page whereas entering http://www.sufinawaz.com took me to the homepage as it should! I wanted http://sufinawaz.com to redirect to http://www.sufinawaz.com and http://sufinawaz.com/blog to http://www.sufinawaz.com/blog.

Solution:
I put the following block of codes right under the rule RewriteEngine On in .htaccess file and everything is a smooth sailing here onwards!

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

PS: 301 is a search engine friendly HTTP redirect.

 

}

How to parse RSS Feed XML from Blogspot using PHP (){

Mighty PHP allows us to do just about anything our hearts desire. Copy and paste the following code to your web page, and you’ll be parsing blog posts from blogspot in no time. The nifty little simplexml_load_file function used here allows you to parse XML files with a level of ease comparable to picking teeth with a toothpick. This function alone opened up a new horizon of creativity for me. I hope you guys find this useful and come up with your own creative ways of exploiting this function for making the world (wide web) a more fun place to live in. Go make Daddy proud!

<?php
// Set name of XML file
$file = "http://[YOUR_BLOGSPOT_ACCOUNT].blogspot.com/atom.xml";
// Load specified XML file or report failure
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
// Load blog entries
$xml =  $xml ->entry;
// Run loop for the number of available entries
foreach( $xml as $row )
{
 // Load the entry publish time 
 $dtime = date("D jS M, Y", strtotime(strtok($row->published, 'T')));
 // Load the link of each blog entry
 $titlelink = $row->link[4][href];
 // Load the text for Comment and comment counts
 $comments = $row->link[1][href];
 $comm = $row->link[1][title][0]; 

 /* Display the contents (use your own imaginations here =).) */
   $row->title
 // Display publish time
   Published on: $dtime
 // Display blog entry content
   $row->content
 // Display number of comments
   $comm
}
?>
}

Oh stop it Robots! Pretty please? (){

So most of us who have a website, usually want the contents to be searchable over the world wide web – I mean that’s the whole point for putting up a website in the first place, right? While we are so eager about our contents getting more hits, there are rare cases however, when we actually do feel a bit shy about the popularity of our pages over search engines like Google. It is then and only then do we look for ways to tell the web robots to stay clear of our pages and not to index them. And since web robots have feelings too, we want to bring it to them as politely as possible – come the meta tags! By adding the following line to your tag, you can do just that, without killing or hurting anyone in the process.

 <meta name="ROBOTS" content="NOINDEX,NOFOLLOW">

Oh don’t you just love happy endings? =)

}