title: Clean URL with Laravel on primary domain only
body: <p>I'm on a <strong>shared hosting</strong> account (no access to the more preferable solutions so I've got to go with a <code>.htaccess</code> rule. </p>
  
  <p>When I implement the pretty URL to remove the public folder I get an <code>HTTP 500</code> error on subdomains. </p>
  
  <p>I'm not versed enough in <code>.htaccess</code> to properly work out the rewrite rule(s) necessary. Can anyone help? My <code>.htaccess</code> looks as follows: </p>
  
  <pre><code>AddType application/x-httpd-php55 .php
  
  RewriteEngine On
  RewriteRule ^(.*)$ public/$1 [L]
  </code></pre>
  
  <p>edit:</p>
  
  <p>What I want to accomplish:</p>
  
  <p><a href="http://example.com" rel="nofollow">http://example.com</a> instead of <a href="http://example.com/public/" rel="nofollow">http://example.com/public/</a></p>
  
  <p>while excluding that from xsubdomain.example.com</p>
  
  <blockquote>
    <p>When I try going to the subdomains I do see the 500 error. When I
    check the server's master error_log it tells me that my request is
    exceeding the limit of 10 internal redirects.</p>
    
    <p>I found that you have a .htaccess file in the public_html directory
    that is responsible. When I temporarily renamed that file I could
    access both of the subdomains.</p>
    
    <p>It appears that you will need to set the .htaccess rules to only
    affect the main directory or exclude the subdomain</p>
  </blockquote>
  
  <hr>
  
  <p>Web Root .htacess</p>
  
  <pre><code>RewriteEngine On
  # Don't do anything if it is blog subdomain for example.
  RewriteCond %{HTTP_HOST} ^blog\. [NC]
  RewriteRule ^ - [L] 
  
  RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /public/([^&amp;\ ]+)
  RewriteRule .* /%1? [R=301,L]
  </code></pre>
  
  <p>RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
  RewriteRule ^(.*)/?$ public/$1 [L]</p>
  
  <p>/public/ .htaccess</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;
  
  
      # Handle Front Controller...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ index.php [L]
  </code></pre>