Skip to content

Instantly share code, notes, and snippets.

@jlopezcur
Last active December 16, 2015 10:19
Show Gist options
  • Save jlopezcur/fd13e83113676bce0f67 to your computer and use it in GitHub Desktop.
Save jlopezcur/fd13e83113676bce0f67 to your computer and use it in GitHub Desktop.
Laravel 5 on subdir (moving public content to project root)
# File: /.htaccess (After move public content to root)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /subfolder/$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
// File: /bootstrap/app.php
..
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
$app->bind('path.public', function ()
{
return base_path() . '/';
});
..
// If you are using Croppa on images dir
Croppa::url('subdir/images/' . $image, $width, $height, array('resize'));
// File: /index.php (After move public content to root)
..
require __DIR__.'/bootstrap/autoload.php';
..
$app = require_once __DIR__.'/bootstrap/app.php';
..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment