That's not bad, but if you want a pure php solution, try this:
put these lines in the header of your file:
<?
if($HTTP_SERVER_VARS["HTTPS"] != "on") {
print <<<HTML
<meta http-equiv="Refresh" content="0; URL=https://{$HTTP_SERVER_VARS["HTTP_HOST"]}$PHP_SELF">
HTML;
}
?>
works great on NT/IIS and LinuxPPC/Apache
Brad McCrorey
Luca Boni wrote:
Try with the following script:
<HEAD>
...
<SCRIPT language="javascript" type="text/javascript">
var lct = location.href;
if ( lct.substring( 0, 7 ) == 'http://' )
location.href = 'https://' + lct.substring( 7 );
</SCRIPT>
...
</HEAD>
Galois wrote:
I want to force https for a certain page, so if the $URI for the page is http://mysite/ put in a header redirect to https://mysite.
how would I go about doing this with php, or am I better off doing it with apache?