$_SERVER['HTTPS'] to check page secure status

HTTPS (Hypertext Transfer Protocol Secure) Reading status of HTTPS
echo $_SERVER['HTTPS']; // Output is off or on
Redirecting based on output ( Read more on header redirect )
if($_SERVER['HTTPS']=='on'){
header ("Location: https://www.plus2net.com"); 	
}else{
header ("Location: https://www.plus2net.com");
}
We are using header redirection here so above code is to be kept at top of the page and should execute before sending any output to browser.

Redirecting after some time lapse.
if($_SERVER['HTTPS']=='on'){
header ("Location: https://www.plus2net.com"); 	
}else{
header( "refresh:5;url=https://www.plus2net.com" );	
echo " You will be redirected after 5 sec , Or <a href=https://www.plus2net.com>Click here of you don't want to wait</a> " ;
}

.htaccess file

To redirect all requests from http to https
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?plus2net\.com
RewriteRule ^(.*)$ https://www.plus2net.com/$1 [R,L]
You need to add one more line at the top of this code if it is not done before inside you file.
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?plus2net\.com
RewriteRule ^(.*)$ https://www.plus2net.com/$1 [R,L]
Don't forget to update / replace plus2net.com with yourdomain.com

Making your pages secure

After installing the certificates, it is time to check your pages.

You might have some internal paths pointing to unsecured pages like
https://www.plus2net.com/images/logo.jpg
Or some old external URL like
https://schema.org
In the presence of such urls you will get in your address bar like this. Address bar before changing links to https
You need to change these URLs in your pages like this. ( https: to https: )
https://www.plus2net.com/images/logo.jpg 
https://schema.org
After changing all urls to https: then your page address bar will look like this ( green https: with lock symbol saying that the data transmission to your browser is encrypted and secure ) Address bar after changing links to https

Search and replace http: to https:

If your site stores URL in database tables , then you can use SQL Replace query to update all your http: to https: present in Links. Here is the query you can use.
update  `table_name` set column1=replace(column1,'http:' ,'https:')  WHERE column1 like '%http:%'

Read more on Replace query

Some useful links regarding migration to https

Secure your site with HTTPS
Overview: Site moves with URL changes
Add a website property


plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer