title: .htaccess - Rewrite subfolder to parent with access to other files in the parent
body: <p>I am trying to create a RewriteRule which would allow me to hide the subfolder name from the URL. It seems pretty straightforward, although I would also like to retain access to the files in the parent folder, and I can't work out how to achieve this and whether this would be possible at all. To make it a bit more clear, my file tree is as follows:</p>
  
  <pre><code>[root]
   L[parent]
     file1
     L[subfolder]
       file2
  </code></pre>
  
  <p>So what I am trying to do, is to be able to rewrite <code>http://example.com/parent/subfolder/file2</code> to <code>http://example.com/parent/file2</code> while still having access to <code>http://example.com/parent/file1</code>. So far I found possible solutions <a href="https://stackoverflow.com/questions/17642122/htaccess-hiding-a-directory-in-the-url-while-preserving-other-files" title="here">here</a> and <a href="https://stackoverflow.com/questions/4804973/htaccess-rewrite-everything-to-parent-directory" title="here">here</a>, but neither of them work as expected. I also had a look at the Apache Aliases, but I am not sure I can use them in this case. Any suggestions please?</p>
  
  <p><strong>Edit</strong>: Here is the current .htaccess:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  
   RewriteEngine On
   RewriteBase /pico/
   RewriteRule sitemap\.xml \?sitemap
   RewriteRule ^parent?$ parent/ [R=301,L] ## Redirects the old file to the index with the same name
   RewriteRule ^parent/subfolder/?$ parent/ [R=301,L] ## Redirects the index of the subfolder to the parent
   RewriteRule ^old-folder/?$ parent/subfolder/new-file1 [R=301,L] ## Redirects the old index to a new file in the subfolder
   RewriteRule ^old-folder/old-file parent/new-file [R=301,L] ## Redirects the files in the old folder to a new file in the parent
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d 
   RewriteRule . index.php [L]
   RewriteRule ^parent/([^/]+)/?$ parent/subfolder/$1 [L]
  
  &lt;/IfModule&gt;
  
  # Prevent file browsing
  Options -Indexes
  </code></pre>
  
  <p>The rules with the comments are just examples, since I am moving the old content to the new site while changing the structure, so there are many more repeating rules just like the examples above.</p>