Hello friends,
I Have face A problem In My Website,Please tell me, How to redirect site from http to https?
You can use .htaccess file and place this code snippets into it (with Linux Hosting & Cpanel/DirectAdmin):
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
or using this code (with specify domain name)
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.*)$ https://ohiwill.com/$1 [R,L]
Agreed with as suggested by @goyums
DO REPLACE EXAMPLE.COM WITH YOUR OWN SITE NAME
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Redirecting your website from HTTP to HTTPS is crucial for security and user trust. It ensures that all information sent between your server and the browsers of your visitors is encrypted. Your web server software determines the approach you choose.
Before you start:- Install an SSL certificate
- Backup your configuration files
Apache (.htaccess file)This is the most common method for shared hosting environments.
- Locate your .htaccess file
- Edit the .htaccess file
- Save and test