jaikar Posted May 25, 2007 Share Posted May 25, 2007 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 Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 25, 2007 Share Posted May 25, 2007 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: Quote Link to comment Share on other sites More sharing options...
jaikar Posted May 25, 2007 Author Share Posted May 25, 2007 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 Quote Link to comment Share on other sites More sharing options...
vynsane Posted May 25, 2007 Share Posted May 25, 2007 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... Quote Link to comment Share on other sites More sharing options...
per1os Posted May 25, 2007 Share Posted May 25, 2007 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"); } ?> Quote Link to comment Share on other sites More sharing options...
jaikar Posted May 25, 2007 Author Share Posted May 25, 2007 Thank you very much !!.. let me check this out and get back .... Thanks again Frost !! ~J Quote Link to comment Share on other sites More sharing options...
jaikar Posted May 25, 2007 Author Share Posted May 25, 2007 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 Quote Link to comment Share on other sites More sharing options...
per1os Posted May 25, 2007 Share Posted May 25, 2007 Yea I didn't test it, I just knew the other guys was an infinite loop. Anyhow glad you got it working right. Good to see someone who can think on their on and modify code given. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.