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.php
to 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
.
But this folder
public
which Laravel goes into is his server’s or Lavarel’s own ?– Diego Souza
If you have access change the deployment script and point to above. Or it’s Shared Server?
– gmsantos
Shared... :/
– José Camelo de Freitas
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...
– José Camelo de Freitas
+1 for the question. Take a look to see if the three methods will help you
– Wallace Maxters