How to redirect from :
https://www.example.com
http://www.example.com
http://example.com
to :
https://example.com
How can I do this with .htaccess
file?
How to redirect from :
https://www.example.com
http://www.example.com
http://example.com
to :
https://example.com
How can I do this with .htaccess
file?
3
Answers
I found the best answer to my question :
It supported all of positions that I said.
You can test it in : Test .htaccess
so you can redirect from :
https://www.example.com
http://www.example.com
http://example.com
to :
https://example.com
with that code.
you can do that by add this code to .htacces file
note if you want remove www from url
Define a middleware for removing www from the url using below command
php artisan make:middleware RedirectToNonWwwMiddleware
and write below code in handle method of that middlewareAdd the middleware to the array of
$middleware
insideappHttpKernel.php
file like belowDefine the url inside your .env file with https like below
At last clear the config cache by running
php artisan config:clear
.