mercredi 13 février 2019

Laravel Use HTTPS

I have project and I installed SSL certificate on ubuntu server. I have done every solution I found but still getting this message every time I open a page.

The requested URL /about was not found on this server.

Here is what I have changed to force Laravel to use https:

1- I have changed .htaccess in my public folder and added these lines

# Added to Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

2- In app->Providers->AppServiceProvider I have add this to boot() function

if (App::environment() === 'production' || App::environment() === 'dev') {
            URL::forceScheme('https');
        }

3- I have created php artisan make:middleware ForceSSL and added the below code to the handle function

 if (!$request->secure() && in_array(env('APP_ENV'), ['stage', 'production'])) {
            return redirect()->secure($request->getRequestUri());
        }

        return $next($request);

and in Kernal.php

\MyApp\Http\Middleware\ForceSSL::class

In .env file I have changed the APP_URL to https:// and I have also changes APP_URL in app.php inside config folder.

What I have missing here? Since two days I couldn't figure out why :(



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire