Running Laravel 5 in a Subdirectory

Running Laravel 5 in a subdirectory (instead of a subdomain or top-level domain) is easy but there's one gotcha.

Step 1: Apache Config

Make sure to alias your subdirectory to the public directory of your Laravel project.

Let's say my site is going to be at My Apache config would look like this:

Alias /laravel-site /path/to/laravel/public
<Directory /path/to/laravel/public>
    AllowOverride All
    Require all granted

Step 2: Laravel .htaccess file

This was that part I got stuck on. The / route was fine but all other routes threw an Internal Server Error (which turned out to be a redirect loop).

To fix this, add the following to your public/.htaccess file:

RewriteBase /laravel-site

Recent Projects

Earthquake Map app

Earthquake Map app

A simple react-native + redux app that reads USGS earthquake data from around the world and displays it on a map.

Get it on Google Play
Get it on iTunes

Center for Non-Profit Excellence

For VIA Studio: A WordPress site with ReactJS+redux event registration and a custom PHP plugin for Salesforce integration and payment processing.

Fund for the Arts - Ecampaign

For VIA Studio: A custom Laravel site for collecting donations.

GE First Build

For VIA Studio: A WordPress site with a custom ReactJS product admin (built into the WordPress admin) as well as Shopify integration.

All Posts