Laravel functions as the root of your site, ie it is a framework that is fully geared towards creating all applications, from your dashboard, to multiple sub-domains (see: link ), example:
Route::group(array('domain' => '{account}.myapp.com'), function()
{
Route::get('user/{id}', function($account, $id)
{
//
});
});
So even if you throw your Laravel project into a folder like /etc/www/porta/admin
or /public_html/portal/admin
it will not recognize when to access:
Because Laravel will search on the routes this /portal/admin
and not this /admin
, so the idea of Laravel is that you design with it all pages, to take advantage of all Views and Models and also make the application scalable , thus avoiding to create different things for the same task. Note that just because you used Laravel to create the whole application does not mean that you will be able to scale it without having the knowledge and experience with this type of thing (however this is out of the subject here) / p>
Fortunately, it is possible to circumvent the routes of Laravel and make it accessible, edit the file app/Http/routes.php
and edit the routes by adding a /portal/admin
prefix, so where do you use:
Route::get('/', ...
It will stay:
Route::get('/portal/admin', ...
An example:
$prefixo = '/portal/admin';
//http://site/portal/admin
Route::get($prefixo, function () {
return view('login');
});
//http://site/portal/admin/dashboard
Route::get($prefixo . '/dashboard', function () {
//...
});
//http://site/portal/admin/logout
Route::get($prefixo . '/logout', function () {
//...
});
If the address changes, you will have to change all prefixes /portal/admin
. I do not know Laravel thoroughly, maybe with group
it is possible to do this more easily.
Note one very important thing, the folder admin
must have the contents of public
, so the other laravel folders will be out of admin
, but if this is not possible, you can put everything within admin
, even to public and create a .htaccess to redirect, as in this answer:
It should look like this in your case:
./public_html (Pasta root da hospedagem)
|--- portal
|--- admin
|--- .htaccess (arquivo .htaccess que você deve criar)
|--- /public
|--- index.php
|--- .htaccess
|--- /app
|--- /bootstrap
|--- /config
|--- /database
The .htaccess file should look like this:
RewriteEngine On
RewriteRule ^ /public/index.php [L]
When accessing http://www.site/portal/admin/
this will do a full redirect to the /public_html/portal/admin/public/index.php
file.
All this comes to be a gambiarra, aiming that Laravel was designed to work as root and there may be some difficulties in using it this way, like other possible incompatibilities, what I recommend is to start thinking in redoing the project (as much as possible).