<?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>Fahdi&#039;s Personal Blog &#187; CodeIgniter</title>
	<atom:link href="http://www.fahdmurtaza.com/myblog/tag/codeigniter/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fahdmurtaza.com/myblog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 30 Aug 2010 09:35:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Thanks Rasmus Lerdorf, you made my day</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/09/12/thanks-rasmus-lerdorf-you-made-my-day.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/09/12/thanks-rasmus-lerdorf-you-made-my-day.html#comments</comments>
		<pubDate>Fri, 12 Sep 2008 04:44:52 +0000</pubDate>
		<dc:creator>ahmed</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[best MVC framework]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Lerdorf]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rasmus]]></category>
		<category><![CDATA[Rasmus Lerdorf]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=499</guid>
		<description><![CDATA[OK folks, I think I had announced on my blog that I am under contract with Packt Publishing to write a book about PHP team oriented development. The official title would be &#8220;PHP Team Development&#8221;. This is not a publicity campaign of my book yet another sigh of relief that what I am doing is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F12%2Fthanks-rasmus-lerdorf-you-made-my-day.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F12%2Fthanks-rasmus-lerdorf-you-made-my-day.html&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>OK folks, I think I had announced on my blog that I am under contract with <a href="http://www.packtpub.com" target="_blank"><strong>Packt Publishing</strong></a> to write a book about PHP team oriented development. The official title would be<strong> &#8220;PHP Team Development&#8221;. </strong></p>
<p>This is not a publicity campaign of my book yet another sigh of relief that what I am doing is even supported by the creator of PHP. Yes his name is <strong>Rasmus Lerdorf</strong>. The guy has been doing quite a research about PHP frameworks. Anyhow, the great news is that he found <a href="http://www.codeigniter.com" target="_blank">CodeIgniter </a>the best optimal framework for PHP MVC based  application development. OK so I am sharing the complete article from sitepoint where I read the news.</p>
<p><span id="more-499"></span></p>
<p class="blogauthor"><span class="regular_author">by <a title="David Peterson's Author Bio" href="http://www.sitepoint.com/articlelist/497">David Peterson</a></span></p>
<p><!-- load needed syntax highlighting brushes --><img src="http://szeged2008.drupalcon.org/files/Rasmus.jpg" alt="" align="right" /> This is the fist time I have heard <a href="http://en.wikipedia.org/wiki/Rasmus_Lerdorf">Rasmus Lerdorf</a> speak and it was entertaining to say the least. Refreshing would another way to describe it, I enjoy hearing real opinions and not holding back — Rasmus doesn’t hold back.</p>
<p>Just a short background, Rasmus Lerdorf is the creator of PHP and still continues as a core developer to the PHP project.</p>
<p><strong>PHP frameworks</strong></p>
<p>In his address he choose to highlight PHP frameworks (Drupal was not spared) and how poor they are at performance. Not only are they slow, but their &#8220;jack-of-all-trades&#8221; attitude leads developers down the wrong path by not using what is best for the job. He continues on by stating that PHP developers really need to think about performance for not only scalability reasons but for green reasons. If programs were more efficient it would cut the number of data centres and would reduce energy needs as a result. In our newly emerging age of energy awareness this does become an important aspect and I am glad that he is raising awareness.</p>
<p>Back to frameworks, he started by discussing a database heavy Twitter mashup that he created. This does a lot of database calls and a lot of behind the scenes work. By hand-tuning it he was able to get on the order of 280 req/sec. By comparison and simple HTML page with nothing but &#8220;Hello World&#8221; served by Apache is just over 600 req/sec. Okay, stage is set (by the way, this was tested on his local machine).</p>
<p><strong>Hello World</strong></p>
<p>How do PHP frameworks score on the &#8220;Hello World&#8221; test? No database calls, just the framework being used in its native tongue to output Hello World. The results were not too good, one of the fastest got just over 120 req/sec, the slowest was 8 req/sec. This is a dramatic difference and of course highlights his argument for performance. Where did Drupal score? Right above 50 req/sec. So not the greatest, but he did make the point that Drupal is not really a framework in the traditional sense. It is a web content management system that can be quickly extended.</p>
<p>So, are there any frameworks that don’t suck? Rasmus did mention that he liked <a href="http://codeigniter.com/">CodeIgniter</a> because it is faster, lighter and the least like a framework.</p>
<p><strong>How to make PHP fast</strong></p>
<p>&#8220;Well, you can’t&#8221; was his quick answer. PHP is simply not fast enough to scale to Yahoo levels. PHP was never meant for those sorts of tasks. &#8220;Any script based language is simply not fast enough&#8221;. To get the speed that is necessary for truly massive web systems you have to use compiled C++ extensions to get true, scaleable architecture. That is what Yahoo does and so do many other PHP heavyweights.</p>
<p><strong>RDF, Semantic Web and the Monkey</strong></p>
<p>RDF in Drupal. Rasmus made a special point of highlighting the importance of embedding structured metadata into the page. RDFa allows you to embed data into your web pages and also lets you create custom vocabularies, or even better, reuse existing vocabularies. Why would you want to do this? Searchmonkey will go out and index this content and open up a rich search API to allow you to do intelligent queries. Well beyond what is possible with traditional search.</p>
<p>Along with rich search you also get enhanced search results. I have blogged about this previously so take a <a href="http://www.sitepoint.com/blogs/2008/03/16/why-rdfa-is-the-only-web-scaleable-metadata-format-for-next-generation-search-engines/">look</a>. It is really cool stuff and I will be discussing it in much more detail over the course of the conference.</p>
<p><strong>Pitching the Semantic Web</strong></p>
<p>What if all Drupal sites had embedded RDFa tags? Well, for one, Yahoo would be very happy. It would play directly into the strengths of Yahoo’s new Semantic Web strategy. They are trying to do interesting things with semantic data but of course they need data — the classic chicken and egg thing.</p>
<p>Rasmus mentioned that Yahoo’s semantic data store can scale to the size of the web so the invitation is open.</p>
<p><strong>The future of Drupal</strong></p>
<p>This is where my focus at Drupalcon is, driving the adoption of semantic technologies within Drupal — I feel that the momentum here will make that a reality. There is a lot of interest, a Semantic Web BoF session was stacked with people with some cool ideas…</p>
<p>More to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/09/12/thanks-rasmus-lerdorf-you-made-my-day.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Convert date formats between PHP and MySQL (mm/dd/yyyy to yyyy-mm-dd)</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/09/08/convert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/09/08/convert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html#comments</comments>
		<pubDate>Mon, 08 Sep 2008 05:26:16 +0000</pubDate>
		<dc:creator>ahmed</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[date conversion]]></category>
		<category><![CDATA[date picker]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mm/dd/yyyy]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[yyyy-mm-dd]]></category>
		<category><![CDATA[yyyy-mm-dd hh:mm:ss]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=412</guid>
		<description><![CDATA[I have a view in HWC where I am using Javascript DHTML date picker script to pick the date and insert into test field. By the way HWC is the PHP-MVC (using codeigniter) application I am working on. So as you see, the date pickers default format is mm/dd/yyyy,  which is not acceptable by MySQL [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F08%2Fconvert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F09%2F08%2Fconvert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I have a view in HWC where I am using Javascript DHTML date picker script to pick the date and insert into test field.  By the way HWC is the PHP-MVC (using codeigniter) application I am working on.</p>
<div id="attachment_446" class="wp-caption alignright" style="width: 310px"><a href="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2008/09/date_picker_view.jpg"><img class="size-medium wp-image-446" title="DHTML Date Picker View" src="http://www.fahdmurtaza.com/myblog/wp-content/uploads/2008/09/date_picker_view-300x164.jpg" alt="Date Picker in dhtml/Javascript " width="300" height="164" /></a><p class="wp-caption-text">Date Picker in dhtml/Javascript </p></div>
<p><span id="more-412"></span>So as you see, the date pickers default format is <strong>mm/dd/yyyy</strong>,  which is not acceptable by MySQL date/time field as it is, so we need a little processing to make MySQL happy enough to store it <img src='http://www.fahdmurtaza.com/myblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Converting  mm/dd/yyyy to yyyy-mm-dd</strong></p>
<p><code>$date=split("/",$_POST['date']);<br />
// where the $_POST['date'] is a value posted by form in mm/dd/yy format<br />
$dated=$date[2]."-".$date[0]."-".$date[1];<br />
// The string dated is now in yyyy-mm-dd format<br />
echo $dated;</code></p>
<p>For example, the date entered through form was 09/02/2009, after processing it will be stored in $dated as 2009-02-09. Pretty kool yeah? Just notice if you have / as  I am happy if helps you. You need help with more similar stuff, post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/09/08/convert-date-formats-between-php-and-mysql-mm-dd-yyyy-to-yyyy-mm-dd.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Codeigniter &#8211; Clean URLs &#8211; Apache mod rewrite : Removing /index.php/ from URL in CodeIgniter Application</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/08/22/codeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/08/22/codeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 07:09:18 +0000</pubDate>
		<dc:creator>ahmed</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[clean]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[igniter]]></category>
		<category><![CDATA[mod]]></category>
		<category><![CDATA[mod rewrite]]></category>
		<category><![CDATA[permalinks]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[urls]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/?p=417</guid>
		<description><![CDATA[This article discusses how you can enable mod rewrite to work with apache server so you can get those clean urls. CodeIgniter has built in support for clean urls so all you have to do is to activate this using the method described in this article.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F08%2F22%2Fcodeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F08%2F22%2Fcodeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>OK readers, here is a simple method to achieve clean urls with your PHP application developed in CodeIgniter.</p>
<p>Please note that this method is applicable only to applications developed in CodeIgniter. Much of the content has been taken from CodeIgniter wiki but rewritten in my own way.<span id="more-417"></span></p>
<p>This article explains how to take away “index.php” from your CI application URLs. However, it does NOT remove the need for Index.php, which is the CI front controller i.e. even though Index.php will not appear in the URL, it still needs to be present at the top level of your site (above the /system/ directory).  To quote the User Guide,</p>
<blockquote><p>You can easily remove this file by using a .htaccess file with some simple rules.</p></blockquote>
<p>You need to perform the following steps to get this working:</p>
<p><strong>1. Create a .htaccess file to configure the rewrite engine</strong></p>
<p><strong>2. Set $config[’index_page’] to an empty string</strong></p>
<p><strong>3. Make sure your apache uses the mod_rewrite module</strong></p>
<p><strong>4. Make sure apache is configured to accept needed .htaccess directives</strong></p>
<p><strong>5. Restart apache and test</strong></p>
<h3>1. Create your .htaccess file</h3>
<p>Create a new file named .htaccess and put it in your web directory</p>
<div class="codeblock"><code> <span style="color: #007700;">&lt;</span><span style="color: #ffffff;">IfModule mod_rewrite</span><span style="color: #007700;">.</span><span style="color: #ffffff;">c</span><span style="color: #007700;">&gt;<br />
</span><span style="color: #ffffff;">RewriteEngine On<br />
RewriteBase </span><span style="color: #007700;">/</p>
<p><span style="color: #ff8000;">#Removes access to the system folder by users.<br />
#Additionally this will allow you to create a System.php controller,<br />
#previously this would not have been possible.<br />
#'system' can be replaced if you have renamed your system folder.<br />
</span><span style="color: #ffffff;">RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_URI} </span><span style="color: #007700;">^</span><span style="color: #ffffff;">system</span><span style="color: #007700;">.*<br />
</span><span style="color: #ffffff;">RewriteRule </span><span style="color: #007700;">^(.*)$ /</span><span style="color: #ffffff;">index</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span><span style="color: #007700;">/$</span><span style="color: #ffffff;">1 [L]</span></p>
<p><span style="color: #ff8000;">#Checks to see if the user is attempting to access a valid file,<br />
#such as an image or css document, if this isn't true it sends the<br />
#request to index.php<br />
</span><span style="color: #ffffff;">RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_FILENAME} </span><span style="color: #007700;">!-</span><span style="color: #ffffff;">f<br />
RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_FILENAME} </span><span style="color: #007700;">!-</span><span style="color: #ffffff;">d<br />
RewriteRule </span><span style="color: #007700;">^(.*)$ </span><span style="color: #ffffff;">index</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span><span style="color: #007700;">/$</span><span style="color: #ffffff;">1 [L]<br />
</span><span style="color: #007700;">&lt;/</span><span style="color: #ffffff;">IfModule</span><span style="color: #007700;">&gt;</span></p>
<p>&lt;</p>
<p><span style="color: #ffffff;">IfModule </span><span style="color: #007700;">!</span><span style="color: #ffffff;">mod_rewrite</span><span style="color: #007700;">.</span><span style="color: #ffffff;">c</span><span style="color: #007700;">&gt;<br />
</span><span style="color: #ff8000;"># If we don't have mod_rewrite installed, all 404's<br />
# can be sent to index.php, and everything works as normal.<br />
# Submitted by: ElliotHaughin</span></p>
<p></span></code><code><span style="color: #ffffff;">ErrorDocument 404 </span><span style="color: #007700;">/</span><span style="color: #ffffff;">index</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php<br />
</span><span style="color: #007700;">&lt;/</span><span style="color: #ffffff;">IfModule</span><span style="color: #007700;">&gt;</span> </code></p>
</div>
<p>Notes for Windows users:<br />
To create this file you must open Command Prompt and type:<br />
copy con .htaccess [Enter]<br />
[Press CTRL + Z]<br />
A blank .htaccess file will be created. Now you can edit it using Notepad or your favorite text editor and copy the script above.</p>
<p>Note: Most Windows editors will assume that you are attempting to save an .htaccess file as a file with an extension and no filename. The Crimson Editor can be used to create and save .htaccess files and other files that have no filename.</p>
<p>Note: If your site is placed in subfolder specify the path in the “RewriteBase /subfolder/” line.</p>
<h3>2. Set $config[’index_page’]  to an empty string</h3>
<p>Open your</p>
<div class="codeblock"><code> <span style="color: #ffffff;">system</span><span style="color: #007700;">/</span><span style="color: #ffffff;">application</span><span style="color: #007700;">/</span><span style="color: #ffffff;">config</span><span style="color: #007700;">/</span><span style="color: #ffffff;">config</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span> </code></div>
<p>and find the line that assigns $config[’index_page’] a value, usually:</p>
<div class="codeblock"><code> <span style="color: #ffffff;">$config[</span><span style="color: #dd0000;">'index_page'</span><span style="color: #ffffff;">] </span><span style="color: #007700;">= </span><span style="color: #dd0000;">"index.php"</span><span style="color: #007700;">;</span> </code></div>
<p>and change it to:</p>
<div class="codeblock"><code> <span style="color: #ffffff;">$config[</span><span style="color: #dd0000;">'index_page'</span><span style="color: #ffffff;">] </span><span style="color: #007700;">= </span><span style="color: #dd0000;">''</span><span style="color: #007700;">;</span> </code></div>
<p>Save the file.</p>
<h3>3. Make sure your apache has mod_rewrite activated</h3>
<p>This means that the apache must be configured to load the mod_rewrite module (or it might have it compiled-in). For module inclusion, usually you have to look for a line like this in httpd.conf or a file loaded by it (hint: use some quick file search utility to grep files with lines containing ‘rewrite’ string):</p>
<div class="codeblock"><code> <span style="color: #ffffff;">LoadModule rewrite_module </span><span style="color: #007700;">/</span><span style="color: #ffffff;">usr</span><span style="color: #007700;">/</span><span style="color: #ffffff;">lib</span><span style="color: #007700;">/</span><span style="color: #ffffff;">apache2</span><span style="color: #007700;">/</span><span style="color: #ffffff;">modules</span><span style="color: #007700;">/</span><span style="color: #ffffff;">mod_rewrite</span><span style="color: #007700;">.</span><span style="color: #ffffff;">so</span> </code></div>
<p>If you’re running Apache2 type</p>
<div class="codeblock"><code> <span style="color: #ffffff;">a2enmod</span> </code></div>
<p>in the console and when prompted</p>
<div class="codeblock"><code> <span style="color: #ffffff;">rewrite</span> </code></div>
<p>to enable mod_rewrite.</p>
<p>On a Windows machine this line might look this way:</p>
<div class="codeblock"><code> <span style="color: #ffffff;">LoadModule rewrite_module modules</span><span style="color: #007700;">/</span><span style="color: #ffffff;">mod_rewrite</span><span style="color: #007700;">.</span><span style="color: #ffffff;">so</span> </code></div>
<p>If it is commented out (# in front), make sure to uncomment it and save the file. Checking if the corresponding module exists may be a good idea as well (but it usually does).</p>
<h3>4. Make sure apache accepts needed .htaccess directives</h3>
<p>This means that apache is explicitly configured to allow .htaccess files to override those directives that you use in your .htaccess file from step 1. above.</p>
<p>It seems to be sufficient if you add these two lines to your &lt;Directory&gt; section where you configure the document root for your CI application:</p>
<div class="codeblock"><code> <span style="color: #007700;">&lt;</span><span style="color: #ffffff;">Directory </span><span style="color: #dd0000;">"/some/absolute/path/htdocs"</span><span style="color: #007700;">&gt;<br />
...<br />
</span><span style="color: #ffffff;">Options FollowSymLinks<br />
AllowOverride FileInfo<br />
</span><span style="color: #007700;">...<br />
&lt;/</span><span style="color: #ffffff;">Directory</span><span style="color: #007700;">&gt;</span> </code></div>
<p>There might be other Options listed, just make sure you have <strong>FollowSymLinks</strong> as well.</p>
<p>Should you get a 500 Internal Server Error, try the following syntax:</p>
<div class="codeblock"><code> <span style="color: #007700;">&lt;</span><span style="color: #ffffff;">Directory </span><span style="color: #dd0000;">"/some/absolute/path/htdocs"</span><span style="color: #007700;">&gt;<br />
</span><span style="color: #ffffff;">Options Indexes Includes FollowSymLinks MultiViews<br />
AllowOverride AuthConfig FileInfo<br />
Order allow</span><span style="color: #007700;">,</span><span style="color: #ffffff;">deny<br />
Allow from all<br />
</span><span style="color: #007700;">&lt;/</span><span style="color: #ffffff;">Directory</span><span style="color: #007700;">&gt;</span> </code></div>
<h3>5. Restart apache and test your application</h3>
<p><strong>Works? Congratulations!</strong></p>
<p>Doesn’t work? Ehrrr… well, do not give up; equip yourself with patience, double check all steps above and if it still does not work, post on the forum giving all details of your setup.</p>
<h3>How does URL rewriting work?</h3>
<div class="codeblock"><code> <span style="color: #007700;">&lt;</span><span style="color: #ffffff;">IfModule mod_rewrite</span><span style="color: #007700;">.</span><span style="color: #ffffff;">c</span><span style="color: #007700;">&gt;<br />
...<br />
&lt;/</span><span style="color: #ffffff;">IfModule</span><span style="color: #007700;">&gt;</span> </code></div>
<p>Do what is inside only if Apache has the mod_rewrite feature (by in place compilation, or loaded module).</p>
<div class="codeblock"><code> <span style="color: #ffffff;">RewriteEngine On</span> </code></div>
<p>Activate the URL rewriting engine, if not already done (in main Apache configuration file.</p>
<div class="codeblock"><code> <span style="color: #ffffff;">RewriteBase </span><span style="color: #ff8000;">/</span> </code></div>
<p>Define the part of the URL that won’t change nor be used for rewriting. In fact, this part will be removed before processing, and prepended after processing. This’s a good way to use subfolder-independent rewrite rules. For example, if your CodeIgniter index.php is placed in a virtual host directory, like /tests/, set RewriteBase to /tests/.</p>
<div class="codeblock"><code> <span style="color: #ffffff;">RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_FILENAME} </span><span style="color: #007700;">!-</span><span style="color: #ffffff;">f</span> </code></div>
<p>Condition to meet for RewriteRule activation. Here, we test if the requested filename does not exist.</p>
<div class="codeblock"><code> <span style="color: #ffffff;">RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_FILENAME} </span><span style="color: #007700;">!-</span><span style="color: #ffffff;">d</span> </code></div>
<p>Same as above, but we test for directory existence.</p>
<div class="codeblock"><code> <span style="color: #ffffff;">RewriteRule </span><span style="color: #007700;">^(.*)$ </span><span style="color: #ffffff;">index</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span><span style="color: #007700;">/$</span><span style="color: #ffffff;">1 [L]</span> </code></div>
<p>If RewriteCond conditions are met, this rule will be applied. It inserts index.php before the requested URI. The $1 represents the part of string enclosed by parentheses in left expression. The [L] means that this rule is the last one if rule is applied (thus stopping rewriting).</p>
<h2>Configuring mod_rewrite in the httpd.conf file</h2>
<p>The Apache mod_rewrite docs say</p>
<blockquote><p>While URL manipulations in per-server context are really fast and efficient, per-directory rewrites are slow and inefficient…</p></blockquote>
<p>. If you have access to your httpd.conf file, you’ll have better performance if you configure the rewrite rules in there.</p>
<p>You can add something like this to your httpd.conf:</p>
<div class="codeblock"><code> <span style="color: #007700;">&lt;</span><span style="color: #ffffff;">IfModule mod_rewrite</span><span style="color: #007700;">.</span><span style="color: #ffffff;">c</span><span style="color: #007700;">&gt;<br />
</span><span style="color: #ffffff;">RewriteEngine On<br />
RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_URI} </span><span style="color: #007700;">!^(/</span><span style="color: #ffffff;">index\</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span><span style="color: #007700;">|/</span><span style="color: #ffffff;">img</span><span style="color: #007700;">|/</span><span style="color: #ffffff;">js</span><span style="color: #007700;">|/</span><span style="color: #ffffff;">css</span><span style="color: #007700;">|/</span><span style="color: #ffffff;">robots\</span><span style="color: #007700;">.</span><span style="color: #ffffff;">txt</span><span style="color: #007700;">|/</span><span style="color: #ffffff;">favicon\</span><span style="color: #007700;">.</span><span style="color: #ffffff;">ico</span><span style="color: #007700;">)<br />
</span><span style="color: #ffffff;">RewriteRule </span><span style="color: #007700;">^(.*)$ /</span><span style="color: #ffffff;">index</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span><span style="color: #007700;">/$</span><span style="color: #ffffff;">1 [L]<br />
</span><span style="color: #007700;">&lt;/</span><span style="color: #ffffff;">IfModule</span><span style="color: #007700;">&gt;</span> </code></div>
<h2>Configuring mod_rewrite and virtual hosting with Apache 2.2</h2>
<div class="codeblock"><code> <span style="color: #007700;">&lt;</span><span style="color: #ffffff;">VirtualHost </span><span style="color: #007700;">*&gt;<br />
</span><span style="color: #ffffff;">ServerName www</span><span style="color: #007700;">.</span><span style="color: #ffffff;">mydomain</span><span style="color: #007700;">.</span><span style="color: #ffffff;">com<br />
DocumentRoot </span><span style="color: #007700;">/</span><span style="color: #ffffff;">path</span><span style="color: #007700;">/</span><span style="color: #ffffff;">to</span><span style="color: #007700;">/</span><span style="color: #ffffff;">ci</span><span style="color: #007700;">/</span><span style="color: #ffffff;">directory<br />
</span><span style="color: #007700;">&lt;</span><span style="color: #ffffff;">Directory </span><span style="color: #007700;">/</span><span style="color: #ffffff;">path</span><span style="color: #007700;">/</span><span style="color: #ffffff;">to</span><span style="color: #007700;">/</span><span style="color: #ffffff;">ci</span><span style="color: #007700;">/</span><span style="color: #ffffff;">directory</span><span style="color: #007700;">&gt;<br />
</span><span style="color: #ffffff;">RewriteEngine On<br />
RewriteBase </span><span style="color: #007700;">/<br />
</span><span style="color: #ffffff;">RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_FILENAME} </span><span style="color: #007700;">!-</span><span style="color: #ffffff;">f<br />
RewriteCond </span><span style="color: #007700;">%</span><span style="color: #ffffff;">{REQUEST_FILENAME} </span><span style="color: #007700;">!-</span><span style="color: #ffffff;">d<br />
RewriteRule </span><span style="color: #007700;">^(.*)$ </span><span style="color: #ffffff;">index</span><span style="color: #007700;">.</span><span style="color: #ffffff;">php</span><span style="color: #007700;">/$</span><span style="color: #ffffff;">1 [L]<br />
</span><span style="color: #007700;">&lt;/</span><span style="color: #ffffff;">Directory</span><span style="color: #007700;">&gt;<br />
&lt;/</span><span style="color: #ffffff;">VirtualHost</span><span style="color: #007700;">&gt;</span></code></div>
<div class="codeblock">Credits: <a href="http://codeigniter.com/wiki/mod_rewrite/" target="_blank">http://codeigniter.com/wiki/mod_rewrite/</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/08/22/codeigniter-clean-urls-apache-mod-rewrite-removing-indexphp-from-url-in-codeigniter-application.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>CodeIgniter: How to set your images path automatically for your site</title>
		<link>http://www.fahdmurtaza.com/myblog/2008/02/13/codeigniter-how-to-set-your-images-path-automatically-for-your-site.html</link>
		<comments>http://www.fahdmurtaza.com/myblog/2008/02/13/codeigniter-how-to-set-your-images-path-automatically-for-your-site.html#comments</comments>
		<pubDate>Wed, 13 Feb 2008 15:49:29 +0000</pubDate>
		<dc:creator>Fahd Murtaza</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Web Development Software]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[igniter]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.fahdmurtaza.com/myblog/2008/02/13/codeigniter-how-to-set-your-images-path-automatically-for-your-site.html</guid>
		<description><![CDATA[Well I was thinking that the old source code I got from the other guy Nouman who was working on this Home Work Center Project that was and is being coded in CodeIgniter was not very much upto date. I fixed the Javascript issues; in fact a lot of them including the JavaScript date picker [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F02%2F13%2Fcodeigniter-how-to-set-your-images-path-automatically-for-your-site.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.fahdmurtaza.com%2Fmyblog%2F2008%2F02%2F13%2Fcodeigniter-how-to-set-your-images-path-automatically-for-your-site.html&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Well I was thinking that the old source code I got from the other guy <em>Nouman</em> who was working on this <em>Home Work Center</em> Project that was and is being coded in <em><a href="http://codeigniter.com/" title="CodeIgniter" target="_blank">CodeIgniter</a> </em>was not very much upto date. I fixed the Javascript issues; in fact a lot of them including the JavaScript date picker calendar. It fits well, works on IE 6, IE7, Safari and Firefox; haven&#8217;t yet checked with others. But I am sure it will!. Anyhow the problem I was facing was that in different folders in Views for <em><a href="http://codeigniter.com/" title="CodeIgniter" target="_blank">CodeIgniter</a> </em>, if we are using images, we have to use relative URLs in most of the pages, which gets quite troublesome sometimes. As long as it is the <em><a href="http://codeigniter.com/" title="CodeIgniter" target="_blank">CodeIgniter</a> </em> I am working on, I don&#8217;t want to use my own includes having setting of the site because this is why we are using <em><a href="http://codeigniter.com/" title="CodeIgniter" target="_blank">CodeIgniter</a> </em>.</p>
<p><strong>Solution:</strong></p>
<p>So cutting short the details, if you want to use the site&#8217;s URL and relative paths according to your site&#8217;s <strong>base url</strong>, here is the solution use <a href="http://codeigniter.com/user_guide/helpers/url_helper.html">site_url()</a>. The link contains all the details you will need to use for your views and it also tells which helpers you need to load. <a href="http://codeigniter.com/user_guide/helpers/url_helper.html"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fahdmurtaza.com/myblog/2008/02/13/codeigniter-how-to-set-your-images-path-automatically-for-your-site.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
