Set Laravel to Standard Level/Directory

Asked

Viewed 2,084 times

4

I have an app Laravel and do the deploy from git to my server. But the problem is that the server always plays deploy inside the public folder, and the Laravel originally is to stay one level above.

Then every time after deploying, I have to go there drag folders from one side to the other... I wonder if there are alternatives to this... A solution using .htaccess or Laravel himself for example...

  • But this folder public which Laravel goes into is his server’s or Lavarel’s own ?

  • If you have access change the deployment script and point to above. Or it’s Shared Server?

  • Shared... :/

  • From the server, Deesouza... When accessing my site, www.site.com the folder that is accessed is the 'public' folder of the server, but Laravel has its own 'public' folder... Then I would have to access my site like this: www.site.com/public to work or play my Laravel manually 1 level above...

  • +1 for the question. Take a look to see if the three methods will help you

1 answer

1

There is a way to settle this by .htaccess and by laravel. And an extra gambit I’ll teach you (maybe it’s the easiest way).

HTACCESS

That 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.phpto the root, i.e. ./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 will have to change the way the files index.php and bootstrap/paths.php are being used by the function require (you’ll have to take the string out /../ that stands at the beginning).

Gambiarra Extra (Powered By Wallace)

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

As follows:

//index.php

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

Of the three methods, I would recommend the htaccess.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.