title: mod_rewrite in Users/<username>/Sites directory on OSX
body: <p>There may be a fairly simple solution to this, but I've been searching for a couple of days and can't find one, soooo...</p>
  
  <p>I'm developing a website on an OS X box (Lion). The working site is hosted at /Users/username/Sites and I've added that directory to /etc/apache2/users/username.conf.  I can view the pages with no problems.</p>
  
  <p>BUT... I'm using CodeIgniter and I want to remove the index.php from the URL.  This should be a fairly simple job for mod_rewrite.  I've added an .htaccess file to the directory (and set AllowOverride All in my conf file above).  After googling around I discovered that I need Options +FollowSymLinks set (I did in the .htaccess file).</p>
  
  <p>The problem with this is that it appears to rewrite the URL from localhost/~username/ to /Users/username/Sites.  Problem with this is that, in that form, the browser simply attempts to DOWNLOAD the index.php file, rather than executing it.  This gets worse when the links are /Users//Sites/index.php/controller/function because those files don't exist... CodeIgniter is meant to take over in the index.php, but only if it is executed.</p>
  
  <p>So I can't remove the Options +FollowSymLinks because that generates Access Forbidden errors, and I can't leave it in for the reasons above.</p>
  
  <p>Interestingly, putting exactly the same website to the /Library/WebServer/Documents directory works fine.  OS X doesn't appear to mind FollowSymLinks to that directory, probably because it is set as the DocumentRoot in httpd.conf</p>
  
  <p>My httpd.conf is stock Lion, except for AllowOverride All on /Library/Webserver/Documents.  mod_rewrite is enabled.</p>
  
  <p>My username.conf is</p>
  
  <pre><code>&lt;Directory "/Users/username/Sites/"&gt;
      Options Indexes MultiViews FollowSymLinks
      AllowOverride All
      Order allow,deny
      Allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>My .htaccess file in the site's directory is</p>
  
  <pre><code>Options +FollowSymLinks
  RewriteEngine on
  RewriteCond $1 !^(index\.php|static|robots\.txt)
  RewriteRule ^(.*)$ index.php/$1 [L]
  </code></pre>
  
  <p>Clearly, I can develop on /Library/WebServer/Documents, but would prefer to do it in my local files.</p>