Configuring Laravel 4 htaccess rules on a remote host

November 1, 2013, 1:59 pm
Author: James Griffiths

  1. Remove ALL of the following - app, bootstrap and vendor directories and server.php file and place them in the root of the server (OUTSIDE of the publicly accessible web root - VERY important from a security perspective)
  2. Remove the following directories: packages and all your images, stylesheets, javascript files and other related assets from the laravel public directory and place those in the web root (public_html directory on our particular unix server)
  3. Finally, assuming your routes are defined correctly and working on the local development server then try using the following htaccess redirect rules:
   Options +FollowSymLinks
   RewriteEngine On
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?/$1 [NC,L,QSA]

After numerous headaches and issues trying to find the htaccess rules to work those were the ones that we found that worked for us!

Hopefully our experiences and what we learned in the process will help anyone struggling with getting Laravel 4 to work on a remote server :)

Categories

« Return to Posts

Post a comment

All comments are welcome and the rules are simple - be nice and do NOT engage in trolling, spamming, abusiveness or illegal behaviour. If you fail to observe these rules you will be permanently banned from being able to comment.