Laravel – Remove public from URL

On any type of server (Apache, Nginx, etc.)

You should point your web server (Nginx, Apache, etc) to the public folder, not to the root folder (where appconfigpublic, etc live).

If you cannot point your web server, you have follow the methods below for specific type of server.

On Apache

Create an .htaccess file in your Laravel root folder with the content below:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

On Nginx

server {
    listen   80 default_server;

    root /var/www/laravel/public/;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
            ...
    }
}

More information about Nginx configuration for Laravel here.