Place Laravel on Default Level / Directory [duplicate]

4

I have a Laravel application and I deploy it via git to my server. But the problem is that the server always throws the deploy into the public folder , and Laravel originally is meant to stay up .

.htaccess or Laravel itself for example ...

    
asked by anonymous 26.10.2015 / 16:07

1 answer

1

There is a way to resolve this by .htaccess and laravel . And an extra gambiarra that I'll teach you (maybe it's the easiest way).

HTACCESS

A of htaccess consists of writing the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/$1

LARAVEL

You will have to move the file public/index.php to the root, or just ./index.php .

Example:

 //index.php (agora fora da pasta public)

 //require_once __DIR__ . '/../bootstrap/start.php'

 require_once __DIR__ . '/bootstrap/start.php'

After that, you'll have to change the way index.php and bootstrap/paths.php files are being used by the require function (you'll have to get the /../ string at the beginning).

Gambiarra Extra (Powered By Wallace)

You can simply create a index.php file in the root and include the file that is within public/index.php .

As follows:

//index.php

require __DIR__ .  '/public/index.php';

Of the three methods, I would recommend htaccess .

    
15.12.2015 / 16:00