<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mario Awad</title>
	<atom:link href="http://www.marioawad.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marioawad.com</link>
	<description>On Software and Web Development</description>
	<lastBuildDate>Sun, 05 Dec 2010 15:07:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Force Secure Pages (SSL / HTTPS) with Zend Framework</title>
		<link>http://www.marioawad.com/2010/12/05/force-secure-pages-ssl-https-with-zend-framework/</link>
		<comments>http://www.marioawad.com/2010/12/05/force-secure-pages-ssl-https-with-zend-framework/#comments</comments>
		<pubDate>Sun, 05 Dec 2010 15:07:49 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=310</guid>
		<description><![CDATA[If you have a PHP web application built using the Zend Framework, securing all its pages becomes very easy. You just go ahead and add the following tiny function to your Bootstrap file: protected function _initForceSSL() { if($_SERVER['SERVER_PORT'] != '443') { header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit(); } What this does is that it captures any non-secure request [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a PHP web application built using the Zend Framework, securing all its pages becomes very easy. You just go ahead and add the following tiny function to your Bootstrap file:</p>
<pre class="brush: php; title: ;">
  protected function _initForceSSL() {
   if($_SERVER['SERVER_PORT'] != '443') {
    header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    exit();
  }
</pre>
<p>What this does is that it captures any non-secure request (Over plain HTTP) and redirects it to HTTPS (HTTP Secure). As an added bonus, Zend Framework will now automatically include HTTPS in all the links that your application outputs (That is, if you&#8217;re using the ZF utility functions to create your links).</p>
<p>Of course, you&#8217;ll need to have an SSL certificate properly configured and installed for your domain name. This is another topic for another post and you&#8217;ll find plenty of resources on this one on the net. As always, I recommend using <a href="http://www.dreamhost.com/r.cgi?482521">DreamHost</a>, they make the whole process of SSL-related tasks a few clicks away and I couldn&#8217;t be happier with their service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2010/12/05/force-secure-pages-ssl-https-with-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating Command Line Colors with PHP</title>
		<link>http://www.marioawad.com/2010/11/25/generating-command-line-colors-with-php/</link>
		<comments>http://www.marioawad.com/2010/11/25/generating-command-line-colors-with-php/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 08:54:38 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=296</guid>
		<description><![CDATA[Generating ANSI (or ASCII) command line colors, or terminal colors, or whatever you call them, is easy with PHP. As I have said in my previous post, ANSI Command Line Colors under Windows, having colored text in the command line is a great help for spotting error or success messages. So here&#8217;s a quick and [...]]]></description>
			<content:encoded><![CDATA[<p>Generating ANSI (or ASCII) command line colors, or terminal colors, or whatever you call them, is easy with PHP. As I have said in my previous post, <a href="http://www.marioawad.com/2010/11/16/ansi-command-line-colors-under-windows/">ANSI Command Line Colors under Windows</a>, having colored text in the command line is a great help for spotting error or success messages. So here&#8217;s a quick and dirty function in PHP to do just that:</p>
<pre class="brush: php; title: ;">

function colorize($text, $status) {
 $out = &quot;&quot;;
 switch($status) {
  case &quot;SUCCESS&quot;:
   $out = &quot;[42m&quot;; //Green background
   break;
  case &quot;FAILURE&quot;:
   $out = &quot;[41m&quot;; //Red background
   break;
  case &quot;WARNING&quot;:
   $out = &quot;[43m&quot;; //Yellow background
   break;
  case &quot;NOTE&quot;:
   $out = &quot;[44m&quot;; //Blue background
   break;
  default:
   throw new Exception(&quot;Invalid status: &quot; . $status);
 }
 return chr(27) . &quot;$out&quot; . &quot;$text&quot; . chr(27) . &quot;[0m&quot;;
}

echo colorize(&quot;Your command has successfully executed...&quot;, &quot;SUCCESS&quot;);
</pre>
</pre>
<h1>References</h1>
<p><a href="http://en.wikipedia.org/wiki/ANSI_escape_code">http://en.wikipedia.org/wiki/ANSI_escape_code</a></p>
<p><a href="http://php.net/manual/en/function.chr.php">http://php.net/manual/en/function.chr.php</a></p>
<p><a href="https://wiki.archlinux.org/index.php/Color_Bash_Prompt">https://wiki.archlinux.org/index.php/Color_Bash_Prompt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2010/11/25/generating-command-line-colors-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ANSI Command Line Colors under Windows</title>
		<link>http://www.marioawad.com/2010/11/16/ansi-command-line-colors-under-windows/</link>
		<comments>http://www.marioawad.com/2010/11/16/ansi-command-line-colors-under-windows/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 12:00:16 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=282</guid>
		<description><![CDATA[Having colored text in the command line is a great help for spotting error or success messages. Unfortunately, those of us developing under Windows do not have this feature by default. Here&#8217;s how to enable it: Download ANSICON from http://adoxa.110mb.com/ansicon/index.html Extract the proper files (Depending on if you have a 32 or 64 bit machine) [...]]]></description>
			<content:encoded><![CDATA[<p>Having colored text in the command line is a great help for spotting error or success messages. Unfortunately, those of us developing under Windows do not have this feature by default. Here&#8217;s how to enable it:</p>
<ol>
<li>Download ANSICON from <a href="http://adoxa.110mb.com/ansicon/index.html">http://adoxa.110mb.com/ansicon/index.html</a></li>
<li>Extract the proper files (Depending on if you have a 32 or 64 bit machine) to c:\ansicon\ (For example). I have a 32 bit machine and hence I extracted the files from inside the x86 folder.</li>
<li>Open a command line prompt and go to c:\ansicon, and then type &#8220;ansicon -i&#8221; without the quotes</li>
<li>Done</li>
</ol>
<p>You can now enjoy the colored output of PHPUnit for example.</p>
<p><a href="http://www.marioawad.com/wp-content/uploads/2010/11/ansi_colors_phpunit.jpg"><img class="alignnone size-full wp-image-286" style="border: 0pt none;" title="ANSI Command Line Colors Example with PHPUnit" src="http://www.marioawad.com/wp-content/uploads/2010/11/ansi_colors_phpunit.jpg" alt="ANSI Command Line Colors Example with PHPUnit" width="677" height="414" /></a></p>
<p><strong>Note</strong>: I have installed ANSICON 1.3 under Windows 7. My best guess is that this process will work for other versions of Windows too.</p>
<p><strong>Update</strong>: I have written a new post on how to <a href="http://www.marioawad.com/2010/11/25/generating-command-line-colors-with-php/">Generate Command Line Colors with PHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2010/11/16/ansi-command-line-colors-under-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing the default Look and Feel of NetBeans</title>
		<link>http://www.marioawad.com/2009/10/25/changing-the-default-look-and-feel-of-netbeans/</link>
		<comments>http://www.marioawad.com/2009/10/25/changing-the-default-look-and-feel-of-netbeans/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 14:27:45 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=131</guid>
		<description><![CDATA[Why change the default Look and Feel? Aesthetics apart, every developer should change the default Look and Feel of NetBeans. Why? because it has an annoying bug. Here&#8217;s what happens: you&#8217;re pumping code in the NetBeans code editor like crazy. You need to switch to another window for a quick copy / paste from your [...]]]></description>
			<content:encoded><![CDATA[<h2>Why change the default Look and Feel?</h2>
<p>Aesthetics apart, every developer should change the default Look and Feel of NetBeans. Why? because it has an annoying bug. Here&#8217;s what happens: you&#8217;re pumping code in the NetBeans code editor like crazy. You need to switch to another window for a quick copy / paste from your eternal library of super code. You press ALT + TAB, you go to your other window, you press CTRL + C, you press ALT + TAB, you&#8217;re in NetBeans again getting ready to kick your paste operation using CTRL + V&#8230; but&#8230; but&#8230; you&#8217;re no longer editing the code!!! You&#8217;re now navigating the menu!!! ANNOYING!!! SHOW STOPPER!!!</p>
<p>Luckily, it turns out this is a bug in the Windows Look and Feel of Java (Which NetBeans uses by default). Time to change it of course. Read on.</p>
<p>Note: I&#8217;m running NetBeans IDE 6.7.1 under Windows XP SP3 / Java SDK 1.6. If you have a different version, this bug might not manifest (Lucky you!!!).</p>
<h2>8 Steps to change the default NetBeans Look and Feel</h2>
<ol>
<li>Download the three .nbm files from <a href="http://kenai.com/projects/nbsubstance/downloads/directory/updates">NetBeans substance look and feel plugin</a></li>
<li>Open NetBeans. Go to Tools -&gt; Plugins -&gt; Downloaded</li>
<li>Click on Add Plugins and add the three downloaded .nbm files (You have to add them one by one)</li>
<li>Make sure the three files are selected, click Install, and follow through</li>
<li>Restart NetBeans</li>
<li>Go to Tools -&gt; Options -&gt; Miscellaneous -&gt; Look and Feel</li>
<li>Choose your preferred Look and Feel and Restart NetBeans again</li>
<li>Enjoy <img src='http://www.marioawad.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<h2>References</h2>
<p>ALT + TAB switching to/from netbeans on Windows<br />
<a href="http://forums.netbeans.org/topic5465.html">http://forums.netbeans.org/topic5465.html</a></p>
<p>NetBeans substance look and feel plugin (Project&#8217;s home page)<br />
<a href="http://kenai.com/projects/nbsubstance/pages/Home">http://kenai.com/projects/nbsubstance/pages/Home</a><a href="http://forums.netbeans.org/topic5465.html"></a></p>
<p>NetBeans IDE &#8211; Look and Feel<br />
<a href="http://netbeanside61.blogspot.com/2008/05/netbeans-ide-look-and-feel.html">http://netbeanside61.blogspot.com/2008/05/netbeans-ide-look-and-feel.html</a></p>
<p>JTattoo<br />
<a href="http://www.jtattoo.net">http://www.jtattoo.net</a></p>
<p>20+ Free Look and Feel Libraries for Java Swing<br />
<a href="http://javabyexample.wisdomplug.com/component/content/article/37-core-java/65-20-free-look-and-feel-libraries-for-java-swings.html">http://javabyexample.wisdomplug.com/component/content/article/37-core-java/65-20-free-look-and-feel-libraries-for-java-swings.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2009/10/25/changing-the-default-look-and-feel-of-netbeans/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sending emails with Zend_Mail using Gmail or Google Apps</title>
		<link>http://www.marioawad.com/2009/10/17/sending-emails-with-zend_mail-using-gmail-or-google-apps/</link>
		<comments>http://www.marioawad.com/2009/10/17/sending-emails-with-zend_mail-using-gmail-or-google-apps/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 17:39:36 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=214</guid>
		<description><![CDATA[Zend Framework is currently one of the best MVC-based frameworks in the PHP world. Zend_Mail is part of Zend Framework and it provides the ability to easily send email messages. If you&#8217;re like me, most web applications you have developed are setup to use Google Apps as their email provider. Here&#8217;s how to send email [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://framework.zend.com">Zend Framework</a> is currently one of the best MVC-based frameworks in the PHP world. <a href="http://framework.zend.com/manual/en/zend.mail.html">Zend_Mail</a> is part of Zend Framework and it provides the ability to easily send email messages. If you&#8217;re like me, most web applications you have developed are setup to use Google Apps as their email provider. Here&#8217;s how to send email messages via Gmail or Google Apps by using Zend_Mail.</p>
<pre class="brush: php; title: ;">
public function send() {

 //Initialize needed variables
 $your_name = 'Mario Awad';
 $your_email = 'your_email@your_domain.com'; //Or your_email@gmail.com for Gmail
 $your_password = 'your_password';
 $send_to_name = 'My Friend';
 $send_to_email = 'myfriend@tempinbox.com';

 //SMTP server configuration
 $smtpHost = 'smtp.gmail.com';
 $smtpConf = array(
  'auth' =&gt; 'login',
  'ssl' =&gt; 'ssl',
  'port' =&gt; '465',
  'username' =&gt; $your_email,
  'password' =&gt; $your_password
 );
 $transport = new Zend_Mail_Transport_Smtp($smtpHost, $smtpConf);

 //Create email
 $mail = new Zend_Mail();
 $mail-&gt;setFrom($your_email, $your_name);
 $mail-&gt;addTo($send_to_email, $send_to_name);
 $mail-&gt;setSubject('Hello World');
 $mail-&gt;setBodyText('This is the body text of the email.');

 //Send
 $sent = true;
 try {
  $mail-&gt;send($transport);
 }
 catch (Exception $e) {
  $sent = false;
 }

 //Return boolean indicating success or failure
 return $sent;

}
</pre>
<p>In addition to the above code, please note the following:</p>
<ul>
<li>You must enable the &#8220;php_openssl&#8221; extension to use the SSL transport protocol (Which is needed for Gmail and Google Apps). All you have to do is open your &#8220;php.ini&#8221; file and uncomment the line that includes the &#8220;php_openssl&#8221; extension (Search for &#8220;php_openssl&#8221; and you&#8217;ll find it).</li>
<li>I found many resources on the web stating that you should use the TLS transport protocol (They never mention how to use or setup the SSL transfer protocol). This didn&#8217;t work in my tests and always resulted in a timeout error.</li>
<li>Yes, you must use &#8220;smtp.gmail.com&#8221; as your SMTP host even if you&#8217;re configuring the application for Google Apps. In other words, don&#8217;t use &#8220;smtp.yourdomain.com&#8221;.</li>
</ul>
<p>I hope this small tutorial saves you some headaches. Cheers <img src='http://www.marioawad.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2009/10/17/sending-emails-with-zend_mail-using-gmail-or-google-apps/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Capture the output of var_dump in a string</title>
		<link>http://www.marioawad.com/2009/07/11/capture-the-output-of-var_dump-in-a-string/</link>
		<comments>http://www.marioawad.com/2009/07/11/capture-the-output-of-var_dump-in-a-string/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 11:43:15 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=199</guid>
		<description><![CDATA[Introduction You are programming in PHP and you have an array variable that you&#8217;d like to explore at different execution paths. Of course, the best way is to use a PHP debugger like xdebug or Zend Debugger, but, what happens when you&#8217;re too lazy to install a debugger? What happens when you don&#8217;t want or [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>You are programming in PHP and you have an array variable that you&#8217;d like to explore at different execution paths. Of course, the best way is to use a PHP debugger like <a href="http://xdebug.org">xdebug</a> or <a href="http://www.zend.com/en/community/pdt">Zend Debugger</a>, but, what happens when you&#8217;re too lazy to install a debugger? What happens when you don&#8217;t want or can&#8217;t install a debugger and you just need to check the content of that array by dumping it in your log file? Well, you might think you&#8217;re stuck, but, read on&#8230;</p>
<h2>What is var_dump?</h2>
<p>The <a href="http://www.php.net/var_dump">var_dump manual page</a> states that var_dump displays structured information about one or more expressions that includes its type and value. Arrays and objects are explored recursively with values indented to show structure.</p>
<p>The problem is that var_dump outputs its result directly to the browser, how can you capture its output in a string variable? read on&#8230;</p>
<h2>Using output control functions for the solution</h2>
<p>Output control functions can be used to capture and redirect the standard output. For more details, read the <a href="http://www.php.net/manual/en/ref.outcontrol.php">PHP manual on output control functions</a>, of course.</p>
<p>Here&#8217;s the solution:</p>
<pre class="brush: php; title: ;">
function varDumpToString ($var)
{
    ob_start();
    var_dump($var);
    $result = ob_get_clean();
    return $result;
}
//
//Example usage:
//    $data = array('first', 'second', 'third');
//    $result = varDumpToString($data);
//
</pre>
<p>All you have to do now is call the varDumpToString function. Happy coding <img src='http://www.marioawad.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2009/07/11/capture-the-output-of-var_dump-in-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hide Gmail&#8217;s spam count</title>
		<link>http://www.marioawad.com/2009/06/18/hide-gmail-spam-count/</link>
		<comments>http://www.marioawad.com/2009/06/18/hide-gmail-spam-count/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 17:34:28 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Quick tips]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=144</guid>
		<description><![CDATA[Does the spam count in Gmail bother you? It certainly does. Are you too lazy to delete your spam messages every few minutes? Of course you are. Would you like to preserve your spam messages just in case they might contain a legitimate email? Of course you would love to. You hate using third party [...]]]></description>
			<content:encoded><![CDATA[<p>Does the spam count in Gmail bother you? It certainly does.</p>
<p>Are you too lazy to delete your spam messages every few minutes? Of course you are.</p>
<p>Would you like to preserve your spam messages just in case they might contain a legitimate email? Of course you would love to.</p>
<p>You hate using third party tools such as <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a> scripts to accomplish this very simple task? Of course you do.</p>
<p>Well, you&#8217;re in luck. I found this <a href="http://lifehacker.com/software/gmail/get-rid-of-gmails-unread-spam-count-323944.php">quick tip at Lifehacker</a> and thought it&#8217;s too good not to be shared. The idea is to create a filter telling Gmail that all incoming spam messages should be marked as read. Of course, Gmail will keep spam messages for 30 days, giving you enough time to rescue legitimate email when you get that angry call from a customer or friend (Ummm&#8230; euhh&#8230; why didn&#8217;t you reply to my email yet!!!).</p>
<p style="text-align: center;"><img class="size-full wp-image-188 aligncenter" title="Gmail Spam Filter Creation Screenshot" src="http://www.marioawad.com/wp-content/uploads/2009/06/gmail-spam-filter-creation.png" alt="Gmail Spam Filter Creation Screenshot" width="450" height="150" /></p>
<p>What you have to do is create a new filter, add &#8220;in:spam&#8221; in the &#8220;Has the words&#8221; field, click next, ignore the warning given by Gmail (because, well, contrary to what they say, it works!!!), choose &#8220;Mark as read&#8221;, and click create filter.</p>
<p>Simple, efficient, and clean. Enjoy <img src='http://www.marioawad.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2009/06/18/hide-gmail-spam-count/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>URL Rewriting for CodeIgniter</title>
		<link>http://www.marioawad.com/2009/05/19/url-rewriting-for-codeigniter/</link>
		<comments>http://www.marioawad.com/2009/05/19/url-rewriting-for-codeigniter/#comments</comments>
		<pubDate>Tue, 19 May 2009 17:43:11 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=99</guid>
		<description><![CDATA[What is URL Rewriting? URL rewriting provides shorter and more relevant-looking links to web pages on your site. This improves the readability and the search rankings of your URLs. For example, URL &#8220;a&#8221; can be rewritten as URL &#8220;b&#8221;. a) http://example.com/index.php?section=casting b) http://example.com/casting There are many articles on the web discussing the benefits of shorter [...]]]></description>
			<content:encoded><![CDATA[<h2>What is URL Rewriting?</h2>
<p>URL rewriting provides shorter and more relevant-looking links to web pages on your site. This improves the readability and the search rankings of your URLs. For example, URL &#8220;a&#8221; can be rewritten as URL &#8220;b&#8221;.</p>
<p>a) http://example.com/index.php?section=casting<br />
b) http://example.com/casting</p>
<p>There are many articles on the web discussing the benefits of shorter and more relevant URLs. Let me add to them that you get to hide the used technology from both search engines and users. You&#8217;ll also have a better time migrating to a different platform in case you need to. For example, if you build your web application on top of ASP.NET and use URL Rewriting, you can easily migrate to PHP (Recommended, of course) without changing your links and hence without losing all the search-ranking score for those links.</p>
<h2>CodeIgniter Default URLs</h2>
<p>By default, CodeIgniter uses a segment-based approach to represent URLs. Unfortunately,  CodeIgniter includes the annoying &#8220;index.php&#8221; file name in the URL. For example:</p>
<p>http://example.com/index.php/products/view/shoes.</p>
<p>Now, the CodeIgniter manual mentions that it&#8217;s very simple to remove the &#8220;index.php&#8221; part from the URL using the following .htaccess file:</p>
<pre class="brush: plain; title: ;">
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
</pre>
<p>Problem solved? Not really. This didn&#8217;t work on my local machine nor on my online hosting account (<a href="http://www.dreamhost.com/r.cgi?482521">Dreamhost</a>). Why? I don&#8217;t know. I don&#8217;t care. I don&#8217;t currently have the time to find out why.</p>
<p>Having already installed WordPress, I remembered that their .htaccess file works offline and online (at least in my case). I started playing around with it, checked some online resources, and devised two solutions. The local solution works on my local machine with the XAMPP server installed on it and the online solution works on my Dreamhost account.</p>
<h2>The Local Solution</h2>
<pre class="brush: plain; title: ;">
RewriteEngine On
RewriteBase /ci/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
</pre>
<p>The only change you need to make is to &#8220;ci&#8221; (on lines 2 and 5) which is the folder where you have your CodeIgniter application installed. In brief, this rewrite file tells your web server to apply the rewrite rule whenever a file or a directory is not found on the server. For example, if you invoke URL &#8220;c&#8221;, the &#8220;contact&#8221; folder is not found on your server (Since CodeIgniter files are in the &#8220;system&#8221; folder), and accordingly the URL is rewritten to &#8220;d&#8221;. This rewrite allows CodeIgniter to execute successfully (By using URL &#8220;d&#8221;) while giving you the benefits of shorter URLs (URL &#8220;c&#8221;).</p>
<p>c) http://localhost/ci/contact<br />
d) http://localhost/ci/index.php/contact</p>
<h2>The Online Solution</h2>
<pre class="brush: plain; title: ;">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</pre>
<p>There are no changes that you need to make for this .htaccess file. However, there&#8217;s one important note to mention. The question mark after &#8220;index.php&#8221; on line 5 is needed on my online hosting account at Dreamhost. You might want to remove it if it doesn&#8217;t work on yours. Again, I didn&#8217;t have the time to investigate why this is the case. Please check the additional resources for more details.</p>
<h2>Conclusion</h2>
<p>I hope this post saves you a few headaches I had to go through to solve this problem. I would love to see such a solution coming out of the box with the next version of CodeIgniter. If you have any hints or additional information regarding URL rewriting in the context of CodeIgniter, please share them in the comments.</p>
<h2>Additional Resources</h2>
<p>CodeIgniter URLs<br />
<a href="http://codeigniter.com/user_guide/general/urls.html"> http://codeigniter.com/user_guide/general/urls.html</a></p>
<p>URL Rewriting for Beginners<br />
<a href="http://www.addedbytes.com/apache/url-rewriting-for-beginners/"> http://www.addedbytes.com/apache/url-rewriting-for-beginners/</a></p>
<p>An easy way to test your RewriteRules against different URLs<br />
<a href="http://civilolydnad.se/projects/rewriterule/"> http://civilolydnad.se/projects/rewriterule/</a></p>
<p>Dreamhost and CodeIgniter URLs<br />
<a href="http://codeigniter.com/forums/viewthread/55620/"> http://codeigniter.com/forums/viewthread/55620/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2009/05/19/url-rewriting-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://www.marioawad.com/2009/03/16/hello-world/</link>
		<comments>http://www.marioawad.com/2009/03/16/hello-world/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 15:02:05 +0000</pubDate>
		<dc:creator>Mario Awad</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.marioawad.com/?p=1</guid>
		<description><![CDATA[The ubiquitous Hello World post is here to stay. For the sake of programming traditions, I&#8217;m not removing it. But I do promise that my next post will be more useful.]]></description>
			<content:encoded><![CDATA[<p>The ubiquitous Hello World post is here to stay. For the sake of programming traditions, I&#8217;m not removing it. But I do promise that my next post will be more useful. <img src='http://www.marioawad.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.marioawad.com/2009/03/16/hello-world/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
