Reputation: 1322
I am trying to redirect all my http requests to https in Laravel 5. Is there any documentation in Laravel 5 for this action. Else, Help me with code how to do that. Thanks in advance.
Upvotes: 1
Views: 1076
Reputation: 6539
You can do redirection from http to https with htaccess file. Put below code in your .htaccess
file.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
OR
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
OR
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
// change example.com with your website domain
// This will redirect all requests received on port 80 to HTTPS.
To understand how rules are working check this link.
In many cases, you can also just add those lines to a file named .htaccess in the folder that you want to redirect http to https.
Now, when a visitor types http://www.yoursite.com/mypage.htm the server will automatically redirect http to https so that they go to https://www.yoursite.com/mypage.htm
Note: You can also redirect a single page from http to http in Apache by using this in your configuration file or .htaccess file:
RewriteEngine On
RewriteRule ^apache-redirect-http-to-https\.html$ https://www.yoursite.com/apache-redirect-http-to-https.html [R=301,L]
This link will also help you.
Hope it will help you :)
Upvotes: 2
Reputation: 4826
hey to redirect any pages you have to use in your controller on top
use Redirect;
in your function you can call which you want like this
return Redirect::route('foldername.filename') //ex - return Redirect::route('consignees.show')
and redirect back you can use this
return redirect()->back();
check this link
Upvotes: 1