<?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>michaelkrol.com &#187; Web Development</title>
	<atom:link href="http://michaelkrol.com/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelkrol.com</link>
	<description>A Web Developer's Blog Highlighting Open Source and OS X</description>
	<lastBuildDate>Mon, 22 Mar 2010 18:01:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Database Exports From phpMyAdmin Add Garbage Text After Every Link</title>
		<link>http://michaelkrol.com/2009/01/11/database-exports-from-phpmyadmin-add-garbage-text-after-every-link/</link>
		<comments>http://michaelkrol.com/2009/01/11/database-exports-from-phpmyadmin-add-garbage-text-after-every-link/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 07:17:34 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Fixit]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=43</guid>
		<description><![CDATA[This is an issue that has plagued me for months and months, and I finally found a way around this VERY strange bug.
For some reason, exporting a database from phpMyAdmin inserts garbage after EVERY LINK in the database content. So if you have a database row with &#60;a href="mylink"&#62; in the data, it will end ]]></description>
			<content:encoded><![CDATA[<p>This is an issue that has plagued me for months and months, and I finally found a way around this VERY strange bug.</p>
<p>For some reason, exporting a database from phpMyAdmin inserts garbage after EVERY LINK in the database content. So if you have a database row with <code>&lt;a href="mylink"&gt;</code> in the data, it will end up looking something like <code>&lt;a href="mylink?phpMyAdmin=hxLEzQ1rOQcEE5fSSzkpIuPI8E7"&gt; </code>after export. Obviously, this causes all kinds of issues.</p>
<p>The only way I&#8217;ve found to stop this behavior is to NOT check &#8220;<strong>Save as file</strong>&#8221; when exporting your database. Just click &#8220;<strong>Go</strong>&#8221; and let the dump print to screen. Then copy/paste it into a text file (save as .sql) and import that into your database. If the export is too large to print to screen, you&#8217;ll have to manually do a search and replace on the resulting .sql file. The hash that comes after ?phpMyAdmin= is different on every export, but luckily it&#8217;s the same in each dump file &#8211; meaning it&#8217;s relatively easy to find it and replace it.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2009/01/11/database-exports-from-phpmyadmin-add-garbage-text-after-every-link/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Set media=print Using The CakePHP CSS HtmlHelper</title>
		<link>http://michaelkrol.com/2008/07/18/set-mediaprint-using-cakephp-css-helper/</link>
		<comments>http://michaelkrol.com/2008/07/18/set-mediaprint-using-cakephp-css-helper/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 18:17:22 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2008/07/18/set-mediaprint-using-cakephp-css-helper/</guid>
		<description><![CDATA[It seemed so simple, yet it took forever to figure this one out. I&#8217;ve been using CakePHP for several projects lately, and I&#8217;m really enjoying using it. But much of the documentation is lacking. Luckily there are plenty of blogs detailing the progress of this framework and what can be done with it. But I ]]></description>
			<content:encoded><![CDATA[<p>It seemed so simple, yet it took forever to figure this one out. I&#8217;ve been using <a href="http://cakephp.org" title="CakePHP" target="_blank">CakePHP</a> for several projects lately, and I&#8217;m really enjoying using it. But much of the documentation is lacking. Luckily there are plenty of blogs detailing the progress of this framework and what can be done with it. But I searched in vain for quite a while on how to create a link to a css file and designate it for &#8220;print&#8221; only.</p>
<p>Here&#8217;s how to create a link to a stylesheet and set the media type to &#8220;print&#8221;:</p>
<p><code>$html-&gt;css(array('filename'), 'stylesheet', array('media' =&gt; 'print'));</code></p>
<p>That will output the following code:</p>
<p><code>&lt;link href="/css/filename.css" rel="stylesheet" type="text/css" media="print" /&gt;</code></p>
<p>Hope that helps the next person trying to figure this one out.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2008/07/18/set-mediaprint-using-cakephp-css-helper/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Local Web Development With OS X 10.5 (Leopard)</title>
		<link>http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/</link>
		<comments>http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 05:28:50 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/</guid>
		<description><![CDATA[With the release of Leopard last Friday, it appears the bulk of my previous tutorials are now taken care of out of the box. mod_rewrite is enabled by default, and a decent (but not robust) installation of PHP 5.2.4 is ready to go &#8211; it only needs to be uncommented in the Apache configuration file.
The ]]></description>
			<content:encoded><![CDATA[<p>With the release of Leopard last Friday, it appears the bulk of my <a href="http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/" title="mod_rewrite on OS X 10.4">previous</a> <a href="http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/" title="Local Web Development With OS X 10.4">tutorials</a> are now taken care of out of the box. mod_rewrite is enabled by default, and a decent (but not robust) installation of PHP 5.2.4 is ready to go &#8211; it only needs to be uncommented in the Apache configuration file.</p>
<p>The PHP installation is missing some key extensions, like PostgreSQL support and the GD library to name a few. But the majority of commonly used extensions are ready to go. <a href="http://www.entropy.ch/blog/Mac+OS+X/2007/10/30/Leopard-Four-Way-Universal-Binaries.html" title="Marc Liyanage">Marc Liyanage</a> is already on the case and working out the kinks for his own installer including those additions. The only thing missing at this point is <a href="http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg">MySQL support</a> for Leopard. As of this writing, there is no installer available yet.</p>
<p>The rest of this post assumes you are working from a clean install or an &#8220;archive and install&#8221; of 10.5. I&#8217;m not sure what the Apache configuration files may look like if you simply upgraded from 10.4 or 10.3 &#8211; if they are clean this should work just fine.</p>
<p>Open the Apache configuration file (I&#8217;m using <a href="http://macromates.com/" title="TextMate">TextMate</a>, which is where the &#8216;mate&#8217; command comes from):<br />
<code>$ mate /etc/apache2/httpd.conf</code><br />
and scroll to line 114 &#8211; it should look like this:<br />
<code>#LoadModule php5_module        libexec/apache2/libphp5.so</code><br />
Just remove the comment:<br />
<code>LoadModule php5_module        libexec/apache2/libphp5.so</code></p>
<p>To enable Virtual Hosts, uncomment line 461:<br />
<code>Include /private/etc/apache2/extra/httpd-vhosts.conf</code><br />
and add your own directories in your <code>/etc/apache2/users/you.conf</code> file. Similar to the 10.4 configuration, change the first two lines (inside <code>&lt;Directory "/Users...&gt;</code>) like so:<br />
<code>Options All<br />
AllowOverride All</code><br />
and add your Virtual Host directives after that:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites<br />
ServerName localhost<br />
&lt;/VirtualHost&gt;</code></p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites/devsite<br />
ServerName devsite<br />
&lt;/VirtualHost&gt;</code></p>
<p>Restart Apache:<br />
<code>$ sudo apachectl restart</code><br />
and you&#8217;re all set.</p>
<p>The only thing left to do is update your hosts file:<br />
<code>$ mate /etc/hosts</code><br />
and add whatever you used for your ServerName after the other entries:<br />
<code>127.0.0.1  devsite</code></p>
<p>Enjoy!</p>
<p>Now I need to figure out if those <a href="http://weblog.rubyonrails.org/2006/8/7/ruby-on-rails-will-ship-with-os-x-10-5-leopard" title="Ruby on Rails in OS 10.5?">rumors</a> of Ruby on Rails out of the box are true&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Save Time (and code) Using Virtual Hosts For Local OS X Web Development With mod_rewrite</title>
		<link>http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/</link>
		<comments>http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 06:38:33 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development/</guid>
		<description><![CDATA[UPDATE: This tutorial was written for OS X 10.4 and parts of it are no longer necessary with OS X 10.5. See this post for details.
Using a few built-in tools in OS X, I&#8217;ve found a great way to develop sites as Virtual Hosts on Apache. If you are a web developer working on a ]]></description>
			<content:encoded><![CDATA[<p style="border: 1px solid #000000; padding: 3px; background-color: #F7F7F7">UPDATE: This tutorial was written for OS X 10.4 and parts of it are no longer necessary with OS X 10.5. See <a href="http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/" title="Local Web Development With OS X 10.5 Leopard">this post</a> for details.</p>
<p>Using a few built-in tools in OS X, I&#8217;ve found a great way to develop sites as Virtual Hosts on Apache. If you are a web developer working on a Mac and you need to develop sites using root relative paths without adding a <code>base href</code> tag to every page on your site, this tutorial should help tremendously. Here&#8217;s how it works:</p>
<p>First, make sure you&#8217;ve got <a href="http://www.entropy.ch/software/macosx/php/" title="Marc Liyanage's PHP Installer" target="_blank">PHP</a> and <a href="http://dev.mysql.com/downloads/" title="MySQL Download Page" target="_blank">MySQL</a> installed &#8211; those are the only two things you should need to install outside of the stock OS X configuration.</p>
<p>Next, follow <a href="http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/" title="OS X mod_rewrite Fix" target="_blank">this tutorial</a> on enabling mod_rewrite on OS X that I&#8217;ve written previously.</p>
<p>The rest will involve some basic command line use, but it&#8217;s pretty painless. As mentioned in the <a href="http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/" title="OS X mod_rewrite Fix" target="_blank">mod_rewrite tutorial</a>, I highly recommend <a href="http://macromates.com/" title="TextMate" target="_blank">TextMate</a> for editing the configuration files. If you&#8217;re a UNIX purist, there&#8217;s always <a href="http://en.wikipedia.org/wiki/Vi" title="vi text editor" target="_blank">vi</a>.</p>
<p>For this example, create a new folder in your <code>/Users/yourname/Sites</code> folder called <code>devsite</code> and place some files there (a simple html or php file with something to output in a browser will do).</p>
<ol>
<li>Open your <code>httpd.conf</code> file and enable Virtual Hosts:<br />
<code>$ mate /etc/httpd/httpd.conf</code><br />
Around line 1063 (almost at the bottom of the file),  you should find and uncomment this line:<br />
<code>NameVirtualHost *:80</code></li>
<li>Open your users.conf file and add a Virtual Host directive:<br />
<code>$ mate /etc/httpd/users/yourname.conf</code><br />
After the <code>&lt;Directory&gt;...&lt;/Directory&gt;</code> portion, add the following:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites<br />
ServerName localhost<br />
&lt;/VirtualHost&gt;</code></p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites/devsite<br />
ServerName devsite<br />
&lt;/VirtualHost&gt;</code></p>
<p>Keeping the <code>localhost</code> portion at the top will still allow you to view the root of the server and anything in it&#8217;s directory at <em>http://localhost</em>.</li>
<li>Open your <code>hosts</code> file and add your new site name to bypass DNS:<br />
<code>$ mate  /etc/hosts</code><br />
Make sure these three lines stay at the top:<br />
<code>127.0.0.1                localhost<br />
255.255.255.255    broadcasthost<br />
::1                            localhost</code><br />
And add this line after it:<br />
<code>127.0.0.1                devsite</code></li>
<li>Restart Apache<br />
<code>$ sudo apachectl restart</code></li>
</ol>
<p>You can now view your local files in your browser at <a href="http://devsite" title="This link will only work AFTER you finish the tutorial">http://devsite</a>.</p>
<p>Let&#8217;s step back and look at what we&#8217;ve done and why this is so useful.</p>
<p>Most likely, until now, you were viewing local development sites by going to something like <em>http://localhost/~yourname/devsite/fancy/url</em> (or <em>127.0.0.1</em> instead of <em>localhost</em>) and doing anything with mod_rewrite meant lots of <code>base href</code> tags and <code>RewriteBase</code> configurations, which in turn meant lots of ../../ paths before your images or included scripts to make things work. Now, viewing the same files in your browser is as easy as <em>http://devsite/fancy/url</em> and all of your paths can begin with a single slash ( / ) meaning it will still work the same when you migrate your site to the live server. Root relative paths are a life saver &#8211; and this setup makes it possible.</p>
<p>It&#8217;s also useful for quick access to commonly used tools, like <a href="http://phpmyadmin.net" title="phpMyAdmin" target="_blank">phpMyAdmin</a>. What I&#8217;ve done is install phpMyAdmin in /Users/me/Sites/phpMyAdmin and set up a Virtual Host like this:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/me/Sites/phpMyAdmin<br />
ServerName admin<br />
&lt;/VirtualHost&gt;</code></p>
<p>In the <code>/etc/hosts</code> file:<br />
<code>127.0.0.1    admin</code></p>
<p>And I can always get to my phpMyAdmin install by simply typing <em>http://admin</em> into the browser.</p>
<p>The reason <em>http://admin</em> works is because most operating systems (even Windows!) will look at the local <code>hosts</code> file first before requesting information from DNS servers. Apache is told to handle requests to <em>http://admin</em> through the Virtual Host we set up. And all of this is done without www&#8217;s or .com&#8217;s.</p>
<p>By now you should realize that you can add as many Virtual Hosts as you like for as many sites as you need. All you need is these three commands:<br />
<code>$ mate /etc/httpd/users/yourname.conf<br />
$ mate /etc/hosts<br />
$ sudo apachectl restart</code></p>
<p>This can also be done on Windows, but it takes a little more work, and would of course work the same as described above on Linux/UNIX. If anyone would find it useful, let me know and I&#8217;ll post a new tutorial on the same method for Windows developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Change Your Domain Name and Keep Your Incoming Links With .htaccess And mod_rewrite</title>
		<link>http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/</link>
		<comments>http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/#comments</comments>
		<pubDate>Wed, 12 Sep 2007 20:56:06 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/</guid>
		<description><![CDATA[When moving our site from ablogapart.org to michaelkrol.com, this handy little bit helped move our entire website with four lines of code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)ablogapart.org [NC]
RewriteRule ^(.*)$ http://michaelkrol.com/$1 [R=301,L]
This reference was extremely helpful.
This RewriteRule lives in the .htaccess file at ablogapart.org and tells any request coming in to that domain to swap ablogapart.org out ]]></description>
			<content:encoded><![CDATA[<p>When moving our site from ablogapart.org to michaelkrol.com, this handy little bit helped move our entire website with four lines of code:</p>
<p><code>Options +FollowSymLinks<br />
RewriteEngine on<br />
RewriteCond %{HTTP_HOST} ^(.*)ablogapart.org [NC]<br />
RewriteRule ^(.*)$ http://michaelkrol.com/$1 [R=301,L]</code></p>
<p><a href="http://www.ilovejackdaniels.com/cheat-sheets/mod_rewrite-cheat-sheet/" title="mod_rewrite cheat sheet" target="_blank">This reference</a> was extremely helpful.</p>
<p>This RewriteRule lives in the .htaccess file at ablogapart.org and tells any request coming in to that domain to swap <em>ablogapart.org</em> out and replace it with <em>michaelkrol.com</em>. This includes ANYTHING after the trailing slash, like a direct link to a previous post. So http://ablogapart.org/this/direct/link gets sent properly to http://michaelkrol.com/this/direct/link</p>
<p>The important part is the <code>[R=301]</code> which sends a 301 (Permanent) Redirect header. That tells search engines that the page has moved permanently.</p>
<p>Just imagine what you&#8217;d have to go through setting up individual forwarding links&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Creating a MySQL Dump File From an External Database</title>
		<link>http://michaelkrol.com/2006/03/16/creating-a-mysql-dump-file-from-an-external-database/</link>
		<comments>http://michaelkrol.com/2006/03/16/creating-a-mysql-dump-file-from-an-external-database/#comments</comments>
		<pubDate>Thu, 16 Mar 2006 19:20:34 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=11</guid>
		<description><![CDATA[I needed to export a MySQL database that was on a different server than the web server and was bound and determined to do it without going through the hassle of installing phpMyAdmin (port 3306 was blocked as well, so I couldn&#8217;t use any GUI tools either). The trick was adding the -h option. Here&#8217;s ]]></description>
			<content:encoded><![CDATA[<p>I needed to export a MySQL database that was on a different server than the web server and was bound and determined to do it without going through the hassle of installing phpMyAdmin (port 3306 was blocked as well, so I couldn&#8217;t use any GUI tools either). The trick was adding the <code>-h</code> option. Here&#8217;s the command line that made some magic:</p>
<p><code>mysqldump -u username -p -h dbserver.host.com --compatible=mysql40 dbname &gt; filetosave.sql</code></p>
<p>The <code>--compatible</code> command was added because the database server was running MySQL 4.1 and we needed the export for MySQL 4.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2006/03/16/creating-a-mysql-dump-file-from-an-external-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP mail() And Gmail &#8211; A Warning on Headers</title>
		<link>http://michaelkrol.com/2005/12/07/php-mail-and-gmail-a-warning-on-headers/</link>
		<comments>http://michaelkrol.com/2005/12/07/php-mail-and-gmail-a-warning-on-headers/#comments</comments>
		<pubDate>Thu, 08 Dec 2005 07:56:51 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Fixit]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=10</guid>
		<description><![CDATA[Today, out of nowhere, we started receiving reports that HTML email the gdiapers.com site was sending were showing up as just that: HTML code and not much else. Running a few tests confirmed these reports&#8230; but only in my gmail account. We went back and checked the reports and sure enough &#8211; they were all ]]></description>
			<content:encoded><![CDATA[<p>Today, out of nowhere, we started receiving reports that HTML email the <a href="http://www.gdiapers.com">gdiapers.com</a> site was sending were showing up as just that: HTML code and not much else. Running a few tests confirmed these reports&#8230; but only in my gmail account. We went back and checked the reports and sure enough &#8211; they were all coming from gmail users.</p>
<p>After some tinkering and futzing around we realized that the Windows line breaks that we had after the headers (<code>\r\n</code>) were the problem. Here&#8217;s an example:</p>
<p>This will show up as two line breaks in gmail and trash your HTML formatting:<br />
<code>$headers = "MIME-Version: 1.0\r\n";</code></p>
<p>This, however, will fix the problem and show up in gmail just fine:<br />
<code>$headers = "MIME-Version: 1.0\n";</code></p>
<p>I&#8217;m sure if you were sending mail from a Windows server this may not be the case, but for those on a Unix box, just stick with <code>\n</code>. Google will thank you by displaying your HTML email the way it was meant to be displayed &#8211; without raw code!</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2005/12/07/php-mail-and-gmail-a-warning-on-headers/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Enable mod_rewrite on OS X 10.4 (Tiger)</title>
		<link>http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/</link>
		<comments>http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/#comments</comments>
		<pubDate>Tue, 22 Nov 2005 06:35:15 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Fixit]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=6</guid>
		<description><![CDATA[Tiger has introduced a new super-confusion level to the stock configuration of Apache. In addition to the httpd.conf file in the /etc/httpd directory, there&#8217;s now a new users directory as well. That directory holds unique config files for each user of the machine. So, if you were to enable mod_rewrite or AllowOverrides in httpd.conf, you ]]></description>
			<content:encoded><![CDATA[<p>Tiger has introduced a new super-confusion level to the stock configuration of Apache. In addition to the httpd.conf file in the <code>/etc/httpd</code> directory, there&#8217;s now a new <code>users</code> directory as well. That directory holds unique config files for each user of the machine. So, if you were to enable mod_rewrite or AllowOverrides in httpd.conf, you may find that it doesn&#8217;t quite cut the mustard in your personal Sites directory. Let&#8217;s take a look:</p>
<p>To enable mod_rewrite:</p>
<ol>
<li>Open <code>/etc/httpd/httpd.conf</code><br />
(I highly recommend <a href="http://macromates.com/" target="_blank">TextMate</a> &#8211; from the command line you can simply type this:<br />
<code>$ mate /etc/httpd/httpd.conf</code><br />
or use the old standards: vi, vim, whathaveyou)</li>
<li>Go to line 223 (if your config file just so happens to jive with mine) and uncomment the following line:<br />
<code>LoadModule rewrite_module     libexec/httpd/mod_rewrite.so</code><br />
(mind the wrap)</li>
<li>Go to line 267 and uncomment the following line:<br />
<code>AddModule mod_rewrite.c</code></li>
<li>Scroll down to line 408 and change the line to read:<br />
<code>AllowOverride All</code><br />
(Some server admins will tell you this may not be the best idea for hosting a live site, but I&#8217;m assuming you&#8217;re using this for local development only, right?)</li>
<li>Uncomment line 454:<br />
<code>AccessFileName .htaccess</code></li>
<li>Restart Apache:<br />
<code>$ sudo apachectl restart</code></li>
</ol>
<p>At this point you should have mod_rewrite happily fixing your ugly URL&#8217;s in the <code>/Library/WebServer/Documents</code> directory, but it&#8217;s not working in your <code>/Users/you/Sites</code> directory. What gives? Here&#8217;s the trick:</p>
<ol>
<li>Open the <code>yourname.conf</code> file in the <code>/etc/httpd/users</code> folder.</li>
<li>Change the first two lines to this:<br />
<code>    Options All<br />
AllowOverride All</code></li>
<li>Give Apache another bounce:<br />
<code>$ sudo apachectl restart</code></li>
</ol>
<p>You should now be seeing friendly url&#8217;s in your very own Sites directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>
