title: Install Laravel 5 app in subdirectory with htaccess
body: <h1>The Setup</h1>
  
  <p>I am trying to install a laravel 5 app in this directory on my server:</p>
  
  <p><code>public_html/myapp/</code></p>
  
  <p>And I want it to be accessed at this URL:</p>
  
  <p><code>http://www.example.com/myapp/</code></p>
  
  <p>I have created this .htaccess rule and placed it in the <code>myapp</code> folder in order to redirect requests :</p>
  
  <pre><code>RewriteEngine on
  RewriteRule ^(.*)$ public/$1 [L]
  </code></pre>
  
  <h1>Problem:</h1>
  
  <p>In my browser when I try to access the app I get redirected URLs like:</p>
  
  <ul>
  <li><code>http://www.example.com/myapp/public/index.php</code></li>
  <li><code>http://www.example.com/myapp/public/index.php/dashboard</code></li>
  </ul>
  
  <p>instead of nice pretty URLs like:</p>
  
  <ul>
  <li><code>http://www.example.com/myapp/</code></li>
  <li><code>http://www.example.com/myapp/dashboard</code></li>
  </ul>
  
  <p>What do I need to change in my .htaccess file to get proper URLs working?</p>
  
  <hr>
  
  <p>Update: The laravel app can be moved elsewhere if needed, as long as the desired URL structure above (with the app accessible at example.com/myapp/) can be achieved. </p>
  
  <p>Update: When I try to access <code>example.com/myapp/dashboard</code> I receive the following error message in the browser: <code>NotFoundHttpException in compiled.php line 7793:</code> with a stack trace that starts with:</p>
  
  <pre><code>in compiled.php line 7793
  at RouteCollection-&gt;match(object(Request)) in compiled.php line 7066
  at Router-&gt;findRoute(object(Request)) in compiled.php line 7038
  at Router-&gt;dispatchToRoute(object(Request)) in compiled.php line 7030
  at Router-&gt;dispatch(object(Request)) in compiled.php line 1989
  at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request))
  </code></pre>
  
  <p>Update: The following .htaccess file is located in the public folder:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
      &lt;IfModule mod_negotiation.c&gt;
          Options -MultiViews
      &lt;/IfModule&gt;
  
      RewriteEngine On
  
      # Redirect Trailing Slashes...
      RewriteRule ^(.*)/$ /$1 [L,R=301]
  
      # Handle Front Controller...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ index.php [L]
  
  &lt;/IfModule&gt;
  </code></pre>