php - Auto secure form on Laravel 4.2
I'm using Laravel 4.2 and everything looks fine. But I have a problem with the SSL when I useForm::open()
Function. It always using HTTP without SSL even when the site is using SSL.
I saw this question: Laravel: HTTPS in Form::open() But there's 2 problems with that: I need to do it manually for each form. and when I program on my Wamp Server, I have HTTP so it won't work on my localhost.
So my question is, How can I auto secure the form if the site is using SSL?
Answer
Solution:
You can create a route group with the
https
option, and insert all of your routes inside that group.Example:
Then your forms should be
https
.Another solution may be just:
Answer
Solution:
You can use
Request::secure()
to check if the request is over HTTPS and use the return value in the URL helper like this:This way you form should automatically use HTTP or HTTPS depending if the current request is using HTTPS or not.