<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://mirmodynamics.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Mirmo Dynamics - Tag - naneau</title>
  <link>http://mirmodynamics.com/</link>
  <atom:link href="http://mirmodynamics.com/feed/tag/naneau/rss2" rel="self" type="application/rss+xml"/>
  <description>Rien de grand ne se fit jamais sans enthousiasme.</description>
  <language>en</language>
  <pubDate>Tue, 18 Nov 2008 12:26:30 +0100</pubDate>
  <copyright>2003-2008 &amp;copy; Geoffrey Bachelet</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Apache and mod_rewrite to subdirectories</title>
    <link>http://mirmodynamics.com/post/2008/06/26/Apache-and-mod_rewrite-to-subdirectories</link>
    <guid isPermaLink="false">urn:md5:e1fd6a0a067fd54399d7439b28f06814</guid>
    <pubDate>Thu, 26 Jun 2008 18:17:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Geekeries</category>
        <category>apache</category><category>mod_rewrite</category><category>naneau</category>    
    <description>    &lt;p&gt;&lt;a href=&quot;http://naneau.nl&quot;&gt;Naneau&lt;/a&gt; just poke me with a little problem he had with &lt;a href=&quot;http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html&quot;&gt;mod_rewrite&lt;/a&gt; when trying to rewrite to a subdirectory. Imagine you've got the following setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apache's document root is /document_root/&lt;/li&gt;
&lt;li&gt;You application's bootstrap is /document_root/public/index.php&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You could come to the following rewrite rules quite easily:&lt;/p&gt;

&lt;pre&gt;
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/index.php/$1 [L]
&lt;/pre&gt;


&lt;p&gt;And you'd be horribly wrong.&lt;/p&gt;


&lt;p&gt;The problem here is that when you hit &lt;code&gt;/&lt;/code&gt; on your server, mod_rewrite will populate &lt;code&gt;%{REQUEST_FILENAME}&lt;/code&gt; it to &lt;code&gt;/document_root/&lt;/code&gt;, which obviously fails the &lt;code&gt;!-d&lt;/code&gt; rewrite condition. By the magic of &lt;code&gt;DirectoryIndex&lt;/code&gt;, you'll eventually hit &lt;code&gt;/index.html&lt;/code&gt; (or whatever your directory index is set to), and there we go for another rewrite magic. At this point, things get a little messy, and if you're like naneau, you'll end up crying while rolling on the floor and calling for help on irc (that's quite a set of hard things to achieve at the same time).&lt;/p&gt;


&lt;p&gt;The solution is not that simple, and actually, I've not found a fully satisfying solution yet (although naneau is satisfied with the partial solution). The quick hack is to simpy remove the &lt;code&gt;!-d&lt;/code&gt; condition. The obvious drawback is that any existing directory &lt;strong&gt;will&lt;/strong&gt; get rewritten, but you'll be able to access the files inside it. I'm still working on a more complete solution, but as it's not my main concerne for the moment, it'll wait a bit (unless someone posts a solution in the comments).&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/06/26/Apache-and-mod_rewrite-to-subdirectories#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/06/26/Apache-and-mod_rewrite-to-subdirectories#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1107</wfw:commentRss>
      </item>
    
</channel>
</rss>