title: Directory Structure and Mod_Rewrite
body: <p>I designed a php/mysql/query based on the idea of a subdirectory per function, so my directory structure looks like this:</p>
  
  <p>public_html\</p>
  
  <pre><code> ..users\ (all user related files are in this folder)
   ..events\ (all event related files are in this folder)
   ..groups\ (all group related files are in this folder)
   ..layouts\ (global header, global footer, and global navigation include files are in here)
  </code></pre>
  
  <p>Any pages in the users,events or groups folder include the header, footer and navigation files so they all keep a theme. Because of this the navigation file has all links set to 
  ../functionfolder/file.php" and it works out because you are usually in one of the function folders.</p>
  
  <p>But I forgot the index file in the public_html, when I include my headers, footers and nav from that directory (not being a sub folder) the "../"'s mess every thing up. </p>
  
  <p>I have already created a separate navigation file that will make files in the high level directory work but I realized that all of my pictures and script includes are messed up.
  (created a separate nav include with no ".."'s)</p>
  
  <p>What I think may be a solution:
  do not use a index.php file home director but create a directory named home and place the index file in there so everything will work out.
  (public_html/home/index.php vs public_html/index.php)
  (not sure how that would work out with the domain)</p>
  
  <p>I have also looked at absolute vs relative links but they end up being a mess working on my computer then uploading them??</p>
  
  <p>Anyone have an Ideas that can help? </p>
  
  <p>Update:
  would something like this work?</p>
  
  <pre><code># Turn on rewrites.
  RewriteEngine on
  
  # Only apply to URLs on this domain
  RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
  
  # Only apply to URLs that aren't already under folder.
  RewriteCond %{REQUEST_URI} !^/folder/
  
  # Don't apply to URLs that go to existing files or folders.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  
  # Rewrite all those to insert /folder.
  RewriteRule ^(.*)$ /folder/$1
  
  # Also redirect the root folder.
  RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
  RewriteRule ^(/)?$ folder/index.php [L]
  </code></pre>