Hello freinds, There i will show you how can redirect PHP website http to https by .htaccess file.
first go to your cpanel filemanager,
open public_html Folder from root.
if there not showing htaccess file then click settings on top menu bars, click show hidden files.. now check .htaccess file.
edit htacces file.
copy this code and paste to htaccess file, write on first line:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [OR]
RewriteCond %{HTTP_HOST} ^mail\.(.*)$
RewriteRule (.*)$ https://yourdomain.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index.php [NC]
RewriteRule ^ / [R,L]
</IfModule>
Replace " https://yourdomain.com " with Your Domain Name.
Note: if You are using cloudflare DNS then first disable cloudfalre https redirect option.. its very important..
if you want disable this option then follow this steps.
STEP 1: first go to cloudflare.com then select your domain,
STEP 2: Go to SSL/TLS Page, click On Edge Certificates
Now Scroll Down And See Always Use HTTPS
remeber that dont use cloaud clare https redirect option.. use only htaccess rewrite rules for redirection if you have Cpanel and your php hosting user..