Laravel redirect() issue


If ELB pass 443 port to 80 port of the web server inside, and disable 80 port on ELB, redirect() will cause problem. Because redirect() always redirect pages to http and it will not display.

Following traditional way to redirect pages will cause session problem in laravel:

header('location:' . $url);


Pass full URL to redirect() function instead of URI only.

return redirect(BASE_URL . 'admin/products');

return redirect('admin/products');

How to set BASE_URL: (in app\Providers\AppServiceProvider.php)

use Illuminate\Support\Facades\App;

    public function boot()
        $env = App::environment();
        if($env == 'local'){
            define('USE_HTTPS', false);
            $base_url = url('/');
            define('USE_HTTPS', true);
            \URL::forceScheme('https');//Important for redirect()!
            $base_url = secure_url('/');

        define('BASE_URL', $base_url . '/');
        define('ASSETS_FRONT', $base_url . '/assets/front/');
        define('ASSETS_ADMIN', $base_url . '/assets/admin/');


Not to close 80 port on ELB.