Today I faced a very simple issue and I am going to share that with all of you. In general when we move our wordpress site from Http to Https then we simple change urls in WordPress->Settings->General
.
But still if any user is going to open your site with http then it will show in http and that’s very bad for you site ranking. For an example my site is on SSL and url is as below:
https://phpinfo.in
Now when you will try to open below urls then you won’t redirect on https automatically
http://phpinfo.in
phpinfo.in
If https://
is not in the prefix, the HTTP link loads instead. To overcome this issue you just need to add the following into your .htaccess in between the
tag:
RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
If there were no additional modifications done to your .htaccess, it should look like the following:
# BEGIN WordPressRewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # Rewrite HTTP to HTTPS RewriteCond %{HTTPS} !=on RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] # END WordPress
Let me know if you have any issue in above so I will help you.
Nice article with point to point information…It reduced some of my time.
Thank you Rahul