title: How do you hide the subfolder using a htaccess file?
body: <p>I am aware that this question has already asked in one way or another, but nor the question description nor the answers were working/satisfactory. So I try to explain the issue as clearly as possible.</p>
  
  <p><strong>SAMPLE FOLDER STRUCTURE</strong></p>
  
  <pre><code>.htaccess
  index.php
  [subfolder-dog]
  ---- index.php
  ---- image.jpg
  ---- [animals]
  --------- index.php
  --------- cat.jpg
  --------- dog.jpg
  --------- frog.jpg
  </code></pre>
  
  <p><strong>SAMPLE DOMAIN</strong></p>
  
  <ul>
  <li>www.dog.com</li>
  </ul>
  
  <p><strong>INTENSION</strong></p>
  
  <p>Guest visiting the website at www.dog.com, should be presented with the subfolder content without ever showing the subfolder in the URL. To make this more clear. <code>http://www.dog.com/image.jpg</code> should show the image and keep that in the URL, not that suddenly it will show <code>http://www.dog.com/subfolder-dog/image.jpg</code>.</p>
  
  <p><strong>HTACCESS (SO FAR)</strong></p>
  
  <pre><code># Turn on Apache mod_rewrite
  RewriteEngine on 
  Options +FollowSymlinks 
  RewriteBase /
  
  # IF THE HOST COMES FROM THE DOMAIN WWW.DOG.COM
  RewriteCond %{HTTP_HOST} ^www.dog.com$ [NC]
  
  # AND IF THE REQUESTED URL DOES NOT ALREADY CONTAIN THE SUBFOLDER-DOG
  RewriteCond %{REQUEST_URI} !^/subfolder-dog/.*$ [NC]
  
  # REWRITE BY PREPENDING EVERY REQUEST WITH SUBFOLDER-DOG
  RewriteRule (.*) subfolder-dog/$1 [L]
  </code></pre>
  
  <p><strong>RESULT</strong></p>
  
  <p>At first sight, this will work as expected. </p>
  
  <ul>
  <li><a href="http://www.dog.com" rel="nofollow">http://www.dog.com</a> - <em>Works and shows the index.php within [subfolder-dog]</em> </li>
  <li><a href="http://www.dog.com/image.jpg" rel="nofollow">http://www.dog.com/image.jpg</a> - <em>Works and shows the image within [subfolder-dog]</em></li>
  <li><a href="http://www.dog.com/animals/frog.jpg" rel="nofollow">http://www.dog.com/animals/frog.jpg</a> - <em>Works and shows the image within [subfolder-dog/animals]</em></li>
  <li><a href="http://www.dog.com/animals/" rel="nofollow">http://www.dog.com/animals/</a> - <em>Works and shows the index.php within [subfolder-dog/animals]</em></li>
  </ul>
  
  <p>The big problem only occurs on directories without trailing slashes.</p>
  
  <ul>
  <li><a href="http://www.dog.com/animals" rel="nofollow">http://www.dog.com/animals</a> - <em>WRONG the URL in the address bar becomes <a href="http://www.dog.com/subfolder-dog/animals" rel="nofollow">http://www.dog.com/subfolder-dog/animals</a>. For some unpredictable reason now the subfolder is no longer hidden in the addressbar</em></li>
  </ul>
  
  <p>This wil become extremely annoying when you try and install WordPress! When putting all the WordPress files within the <code>subfolder-dog</code> folder and going to <a href="http://www.dog.com" rel="nofollow">http://www.dog.com</a> all seems normal. When clicking on "Create configuration file" button, the address bar now says <a href="http://www.dog.com/subfolder-dog/wp-admin/setup-config.php" rel="nofollow">http://www.dog.com/subfolder-dog/wp-admin/setup-config.php</a>. When you correct the URL by removing the subfolder from the URL it requests a file again and it works again.</p>
  
  <p>I've been stuck on this issue for a week now, hopefully someone can shine a light on this subject. It's starting to make me crazy.</p>