Site transition from http to https

Started by Stranger, Jul 25, 2022, 09:34 AM

Previous topic - Next topic

StrangerTopic starter

I transferred the website to a new hosting provider due to inadequate conditions from the previous one. Although I managed to set up almost everything, I am unable to change the site from HTTP to HTTPS. The site is on Wordpress, and the new hosting provider has different settings, which have resulted in 301 errors.
 Thankfully, I have a valid SSL certificate from GoGet for my domain and subdomain. I am unsure about where to start troubleshooting this issue.
  •  
    The following users thanked this post: Sevad

_AnnA_

I understand that you installed an SSL certificate on the server panel?
Check if it works correctly: https://www.sslshopper.com/ssl-checker.html
Next, set up 301 redirects. After connecting the SSL certificate, you should register a page redirect from URLs from http to https in the .htaccess file.
So:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://YOUSITE.DOT/$1 [R=301,L]

Next, change in the WP http panel to https. There should be two lines.
We check the absence of internal links to unprotected documents.
We check for 301 redirects from all pages of the site to similar pages with https.
Update the .xml sitemap to only contain https pages.
We change the link to the sitemap (if it was with the http protocol) in the Robots.txt file.

More or less like this.
  •  

Sevad

I have just done redirects for current (dnray.com) site.
From https to http
And from www. to without-www
See code below in .htaccess

RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} www.dnray.com
RewriteRule (.*) http://dnray.com/$1 [R=301,L]


As I see, it works.
Please verify if site works correctly.
Hope it will be helpful for someone)

_AnnA_

Yes, it does work for www. to without www.
You can do this for https to http :

Rewrite Engine On
RewriteCond %{ENV:HTTPS} =on
RewriteRule ^(.*)$ http://yousite.dot/$1 [R=301,L]

But if there is no active SSL certificate issued by a certification authority, then site visitors will see a browser warning about insecure content. And before the redirect works.

Our friend has the exact opposite task: to send all pages of the site from http to https. Here is another option how to do it:

Rewrite Engine On
RewriteCond %{HTTPS}=off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]

If a circular redirect occurs, you need to add:

Rewrite Engine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Probably so.
  •  

StrangerTopic starter

I've been struggling for a solution for two days without success. We managed to debug something, but the images, which are very numerous, do not have https but http values.
Nothing helps.

It was for this moment that I did the following.
1. Used several plugins, including
Velvet Blues Update and Better Search Replace.
Unsuccessfully.
2. Registered redirects in .htaccess
Changed the site's main protocol from HTTP to HTTPS "Settings → General in the WP admin panel."
3. Looked at all .php and .ini files for http links.
4. Made all absolute links in files relative.
Did not help.
Of course, you can manually make changes to each image, but there are several thousand of them.
  •  

_AnnA_

Classic, mixed content. :)

This is how you can replace http://YOUDOMAIN.com with https://YOUDOMAIN.com in all css files in the current and subdirectories:
find. -name "*.css" -exec sed -i 's|http://YOUDOMAIN.com|https://YOUDOMAIN.com|g' {} \;

Execute a command from the theme directory. Replace the domain with yours.
And just in case, before doing this, make a backup of all files.
  •  

_AnnA_

Stranger, if you have not made changes to mySql, you can make a change request.

Item 16, here.

Be sure to backup your database.
And look at links to external resources. With relinking it seems decided?
  •  

StrangerTopic starter

I did everything, I checked everything. There are no troubles.
Doesn't switch to https. The certificate is valid for another month.
I think there should be a magic button: "Enable https".
How to find it?
  •  

Ali_Pro

Magic button?
Just put Really Simple SSL.
Working with the plugin is not difficult. Everything is described by the developer. The free version should be enough.
Ali.
  •  

StrangerTopic starter

Finally my website is working properly!
Many thanks to everyone who helped in such a nerve-wracking matter!

Ali_Pro, thanks for the link, although it is not entirely correct. I found the plugin by the name in Google, here is the correct link. I think it will help someone else.
  •