Converting HTTP Links to HTTPS
Tips and script for converting a website to secure SSL.
A script is provided to automatically convert internal HTTP links to HTTPS on the local site image. If your site uses a CMS, it will not work, but a CMS with a problem provides tools or plugins for conversion.
Before you turn your http site into https, you need to know some things...
- If you have Facebook or Twitter buttons, or other social sites, the counters will be reset because the URLs have changed!
Only Google + tracks redirects and moves the countdown to a new URL. For the rest... - When using Disqus, all comments will disappear for the same reason.
Disqus offers three migration tools, domain transfer, URL mapping, and a scanner that recognizes 301 redirects and transmits comments to the new address.
Only the latter is really useful, but if we created the other two, then it probably doesn't work well. In my experience, none of the three actually work. - All your internal links and backlinks become redirects. There is nothing to do there for backlinks (and this does not fine the site), but for internal links here you will find a PHP script for converting URLs.
- Embedded videos disappear. The video link must be to https if the page is to https!
The script also works for embedded videos with this option: www.youtube.com .
Redirections
If you have mutual hosting, your hosting can offer you a paid or free SSL certificate using Let's Encrypt.
After you are assigned this certificate, your site has a duplicate, each page has an http-URL and https-URL.
This creates a duplicate glad that it is better to avoid, and for this you need to redirect http pages to https pages .
To do this, you will add redirection code in the .htaccess file to the site root if the server is Apache.
Standard code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This code is offered by GoDaddy and should be universal. If you are not sure that you will finally switch to https, replace the 301 code with 302.
If you have OVH hosting, it offers you the following code:
OBX code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Replace "www.example.com" with the site name.
For another hoster, or if the server is not Apache, you should read their documentation.
Director's script
The script is written in PHP and requires PHP 7 to be pre-installed. This is a simple program that replaces lines in each file.
Before running the script on the site content, you must take several precautions. Even if the code worked great on the sites where I used it, not all sites are designed the same way.
- Make a copy of the site in the temporary directory.
- Run Script.
- Make sure the numbers displayed are consistent.
- View the source code of the pages to see the result.
- Especially pages that would have a special format.
If everything is in order, you can put the content on the Internet.
Download:
To use a script:
- Load the archive and unpack it into a directory, for example, in c:.
- Navigate to the directory containing the site image.
- Enter:
php c:/http2https/tohttps.php www.example.com
- Then put the content on the Internet.
See also...
Advertise. This script is optional, it replaces redirected links with new URLs, but for all domains. However, it is much slower.