title: htaccess directories, files and variables
body: <p>I am trying to get something similar to $_SERVER["PATH_INFO"] but weird server issues are preventing me from using it...</p>
  
  <p>In my application, the links can look like </p>
  
  <pre><code>www.domain.com/folder/file/variable
  www.domain.com/folder/file
  www.domain.com/file/variable or
  www.domain.com/file/
  </code></pre>
  
  <p>With .htaccess, I am trying to get to the proper pages, and not to redirect to the index.php or similar.</p>
  
  <p>So far, I have this, which is not working :)</p>
  
  <pre><code>RewriteRule ^(.+)$ /$1.php # page only
  RewriteRule ^(.+)/(.+)$ /$1.php?x=$2 # page + variable
  RewriteRule ^(.+)/(.+)$ /$1/$2.php # folder / page 
  RewriteRule ^(.+)/(.+)/(.+)$ /$1/$2.php?x=$3 # folder / page + variable
  </code></pre>
  
  <p>I am sure I need to use RewriteCond %{REQUEST_FILENAME} -f to check if the request is a filename, or directory... but I was unable to make it work...</p>
  
  <p>Variables can contain all weird characters - that is why i am matching with dot... Maybe I should try to match file / folder names with a-z only ( since i do not think they will ever contain anything but a-z, _ or - ).</p>
  
  <p>Any help is greatly appreciated, since its been almost two days of agony now :)</p>