signature16 Posted October 7, 2007 Share Posted October 7, 2007 How can I make a script run only if the url starts with HTTPS://. This would be to prevent people from processing credit card data in an insecure environment. Link to comment https://forums.phpfreaks.com/topic/72205-run-script-only-if-https/ Share on other sites More sharing options...
DragonFire-N[R] Posted October 7, 2007 Share Posted October 7, 2007 I'm not entirely sure about this since I haven't done much with secure connections, but I believe when a user goes through a PHP document with a secure connection, a server variable $_SERVER['HTTPS'] exists (I also forget what information the variable contains but for this situation that isn't important). You can do something like this: if ( ! $_SERVER['HTTPS'] ) { header( 'Location: https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ); exit; } Link to comment https://forums.phpfreaks.com/topic/72205-run-script-only-if-https/#findComment-364117 Share on other sites More sharing options...
$username Posted October 7, 2007 Share Posted October 7, 2007 Yes it does sound like PHP has this available to be used Here is the manual http://us3.php.net/reserved.variables Brett Link to comment https://forums.phpfreaks.com/topic/72205-run-script-only-if-https/#findComment-364118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.