I'm trying to redirect http to
in laravel 5.2
trying to do it using middlware Please see code
In karnel.php
\App\Http\Middleware\HttpsProtocol::class,
middlware
public function handle($request, Closure $next)
{
$url = 'https://www.example.com';
if (!$request->secure()) {
return redirect()->secure($url);
}
return $next($request);
}
but getting error
ERR_TOO_MANY_REDIRECTS
And when try to do it using .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# require SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://www%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
it will redirect to
What i want is if anyone type domain.com then it will automatically redirect to
in laravel 5.2