How to Redirect HTTP page to HTTPS in PHP
Here you go!
<?
function secure_page()
{
if ( !isset($_SERVER[‘HTTPS’]) || strtolower($_SERVER[‘HTTPS’]) != ‘on’ )
{
header (‘Location: https://’.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’]);
exit();
}
}
secure_page();
?>
Just put that at the top of your code. I recommend using an include file so that you only have to load one include at the top of your code (keeps it nice and clean).
About Us
Did you know more than 200 clients have worked with PaperStreet for more than 10 years?
Get a Free Website
Analysis and Consultation
Marketing Services
Join the Sales and Marketing News, receive our last insights, tips and best practices.
Our 7 Guarantees
Keeping 2,000+ Clients Happy Since 2001.
1
You Will Love Your Design
We design to please you and your clients
2
Same-Day Support
24-hour turnaround edits during business hours
3
Free Education
We provide knowledge to help you expand
4
No Hidden Charges
We quote flat-rate projects
5
Own Your Site
No strings attached
6
We Create Results
SEO, PPC, content + design = clients
7
We Make Life Easier
One agency for web, branding and marketing