HTTP to HTTPS and non-www to www Redirection Simpliest Brifiest Explanation for Wordpress
Published in
2 min readApr 20, 2019
I have search on the Internet for 10 hours and find exact solutions and here are they.
Decide: You Using CloudFlare?
Answer: No;
Open your.htaccess
file from cpanel file manager. Type the codes written in below.
If the code you have tried doesnt help delete it and try the other.
Don’t forget to change the domain name your own instead of
https://www.yourdomain.com.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
#Dont forget to type the domain name your own on the line below
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
RewriteEngine On
#we replace domain.com/$1 with %{SERVER_NAME}%{REQUEST_URI}.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
#here we dont use www as non www was already redirected to www.
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
For further I kindly invite you to the following pages which I took the answers;
If you are using Cloudflare:
Just watch the video that explain the process step by step.
If you have alternative solves please dont be hesitate to comment so we can be able to help others.
Feel free to applause :D