title: Enforcing trailing slash, and removing index.php with htaccess placed in subfolder
body: <p>I have a CodeIgniter project placed in a subfolder of a domain.
  I want to have my .htaccess (placed in the CodeIgniter subfolder) to do the following, for any url involving the CodeIgniter directory:</p>
  
  <ol>
  <li>Remove "index.php" from any url.</li>
  <li>Always add a trailing slash to any url.</li>
  </ol>
  
  <p>Currently my .htaccess look like this:</p>
  
  <pre><code>
      RewriteEngine on
      RewriteBase /ci_folder/        #This is the CI Subfolder
  
      # Get rid of index.php
      RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
  
      # Add trailing slash
      RewriteCond %{REQUEST_URI} !(.*)/$
      RewriteRule ^(.*[^/])$ $1/ [L,R=301]
  </code></pre>
  
  <p>The problem is, that its only working partially; The index.php is removed fine, but when adding the trailing slash, instead of redirecting to a "fixed" url, its redirecting to the local path, fx. </p>
  
  <p>domain.com/ci_folder/method</p>
  
  <p>is redirected to:</p>
  
  <p>domain.com/home/sites/domain.com/public_html/ci_folder/index.php/method/</p>
  
  <p>which should have been : domain.com/ci_folder/method/ instead! (and also not include any index.php)</p>
  
  <p>--- EDIT ---</p>
  
  <p>This did it for me:</p>
  
  <pre><code>
      RewriteEngine on
      RewriteBase /ci_folder/
  
      RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
      RewriteCond %{REQUEST_FILENAME} -f [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule ^.*$ - [L]
  
      RewriteCond %{REQUEST_URI} !(.*)/$
      # dont rewrite if there was posted here!
      RewriteCond %{REQUEST_METHOD} !POST 
      RewriteRule ^(.*[^/])$ $1/ [L,R=301]
  
      RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
  
  </code></pre>