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
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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

at the top of the page, if you put

 

if(header("Location: http://www.yourURL.com/yourform")) {
   header("Location:https://www.yourURL.com/yourform");
}

 

not tested, not sure, but that might work, or put you on the right path...

 

Link to comment
Share on other sites

I think the above is proned to an infinite loop.

<?php
// if the https value is not set than redirect to the https url.
if(!isset($_SERVER['HTTPS']) || empty($_SERVER['HTTPS'])) {
   header("Location:https://www.yourURL.com/yourform");
}

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.