What's the PHP for....

Talk about and discuss various advancements and achievents in the arts and sciences of invention and modification; computers, sciences, mathematics, and technology for all.
Post Reply
User avatar
AYHJA
392
Posts: 37990
Joined: Fri Sep 17, 2004 2:25 pm
Location: Washington, D.C.
Contact:

#1

Post by AYHJA »

Disabling a script..?

I have my Quantcast script that I want to run only on the http, and not the https...What's the php for that..? We all know my php is spotty at best, so any help here is appreciated...
ImageImage
Image Image

BBcode:
Hide post links
Show post links
WAY
Site Admin
Posts: 2411
Joined: Sat Nov 06, 2004 4:43 am
Location: Sydney, Australia
Contact:

#2

Post by WAY »

Is this to add inside the script itself to REDIRECT to http, if the user visits via https?

BBcode:
Hide post links
Show post links
User avatar
AYHJA
392
Posts: 37990
Joined: Fri Sep 17, 2004 2:25 pm
Location: Washington, D.C.
Contact:

#3

Post by AYHJA »

If the user visits https...

Active on http, inactive on https...
ImageImage
Image Image

BBcode:
Hide post links
Show post links
WAY
Site Admin
Posts: 2411
Joined: Sat Nov 06, 2004 4:43 am
Location: Sydney, Australia
Contact:

#4

Post by WAY »

CODE<?php
function ForceHTTPS()
{
   if( $_SERVER['HTTPS'] != "on" )
   {
       $new_url = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
       header("Location: $new_url");
       exit;
   }
}

ForceHTTPS(); // Perform the actual check during runtime.
?>

Just put that at the top of your PHP script..

BBcode:
Hide post links
Show post links
Post Reply