Remove public from URL - Laravel

Asked

Viewed 1,537 times

0

I’m accessing my website like this: http://localhost/site/public

I’d like to just type http://localhost/site because I want it to work when I put it in the domain too.

Is there any way to resolve this other than by folder changes and yes only via code ? I understand almost nothing from . htaccess.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
  • Good afternoon Diego, use the snippet only for html,css,js that can reproduce the problems. Other languages cannot be reproduced by it.

1 answer

1


Resolution - I do not know if it is the best. It follows below:

I cut the file .htaccess and index php. of the briefcase public and pasted it into the root folder of my website.

And within the index php. changed the path of the folders that start the application.

Of

require __DIR__.'../bootstrap/autoload.php';
$app = require_once __DIR__.'../bootstrap/start.php';

To

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/start.php';

But will it always have to be like this ? Is that in this case I’m inside a folder within of the briefcase www (public_html) of hosting.

I don’t think so, but...

  • had any trouble with the passing of time? with the Assets... ?

  • Never had. But now I don’t do it anymore. I upload all the Laravel project into a folder above the public_html and I just put it in the briefcase public_html the contents of the folder public from Laravel. Beautiful wheel... with PHP higher than 5.6, in the case of my version of Laravel.

Browser other questions tagged

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