Ok so for my register.php page I want to use https however the code that I am using makes my whole site use https how do I make it so only my register page uses https?

Code I'm using:

 if(!isset($_SERVER['HTTPS'])) { header("location: https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);

You want to use https .. do you have ssl certificate ? If you haven’t don’t use https … In your basic code you use $_SERVER['REQUEST_URI']
So check that primitive variable that is the page that you want to apply the rule for and if it is apply it ..

I've also done

if(!isset($_SERVER['HTTPS'])) { header("location: https://........../login.php" );}

but it still makes my whole site https I just want my login.php page to be https, and I do have SSL certificate.

There are a number of ways to get the current page's filename, here's one you could try (I haven't tested):

if(!isset($_SERVER['HTTPS']) && basename($_SERVER['SCRIPT_NAME']) == 'login.php') {
    header("Location: https://........./login.php");
}

It still makes the whole site HTTPS

Member Avatar for LastMitch

It still makes the whole site HTTPS

@TIM_M_91

Read this and try these code here:

https://www.letuslook.org/linux/redirect-http-to-https/

I can honest with you I don't like dealing with any SSL certificate. It's still on going security debate on that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.