PHP 7 Script to Check if the Page Called From HTTP or HTTPS in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments


Welcome folks today in this blog post we will be checking if the page called from http or https in browser using php 7. All the full source code of the application is shown below.




Get Started




In order to get started you need to make an index.php file and copy paste the following code

See also  PHP 7 MPDF Example to Create Table With CSS Styles,Border,Margin in PDF Document Using Browser Full Project For Beginners








if( (empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'off') || $_SERVER['SERVER_PORT'] != 443 )
  // Redirect to secure site
    header("HTTP/1.1 301 Moved Permanently"); 
} else {
  // Do nothing when it is a secure site


Leave a Reply