Jump to content

[SOLVED] http to https .. please help...


jaikar

Recommended Posts

 

Hi Friends...

 

i have a page which is a application form and should be in https. it also works with http. is there any script to redirect the page to https when the request is from http?... the server is IIS. i want only that page to be in https and dont want the whole site in https... can anyone please help !!! ... i really need help on this...

 

Thanks in advance

Jaikar

Link to comment
https://forums.phpfreaks.com/topic/52965-solved-http-to-https-please-help/
Share on other sites

Do you have a certificate installed on the site?

 

If you need data collecting securely you should have the form and processing script in the https: domain so simply link to the form with the good old <a href="https://<?php echo $_SERVER['SERVER_NAME']; ?>/path/to/form">Form</a>...

 

I don't think you should pass info from http: to https:

Hi..

 

Thanks for the responce....

 

i dont want to send the data from http tp https..... also i linked the form as you said ... but the point is.. this form works both in http and https. if a user clicks the link it will take to the https only, but if he uses http:// and the form URL in the browser.. then it will not be secure at all !!.. thats the problem now, so if a user uses http request to the form then it should redirect the form to https...

 

for example, if the user uses http://www.mysite.com/form.php .. this should redirect to https://www.mysite.com/form.php

 

is there any way to do this... in php or javascript ?

 

Thanks

~J

Frosttttttt !!!!!!!!!!!.. Thanks a lott !!

 

it worked perfectly but there is a slight modification to your code....

 

// if the https value is not set than redirect to the https url.

if($_SERVER['HTTPS'] !== "on" || empty($_SERVER['HTTPS'])) {

   header("Location:https://www.mysite.ca/myform.php");

   exit;

}

 

instead of  !isset($_SERVER['HTTPS']) .. it should be $_SERVER['HTTPS'] !== "on" ...  but logic is excelent !

 

Thanks a LOT !!

 

Jaikar

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.