We have a WordPress site, and used to have an SSL certificate.
The site used to be all HTTPS, and now we don’t need the SSL anymore so we let it expire.
We’ve already changed the Site Address and WordPress Address in the admin panel to be http://example.com
.
We have several links out in the wild that link back to us with https://
and if the user accesses the site with https://
the site breaks or the user gets a warning message in their browser.
Bottom line, we need to redirect all https://
traffic to http://
.
I tried couple of plugins (no luck):
and even changed the .htaccess
file (still no luck)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Not sure what else I need to do.
The problem here lies with the fact that before Apache or WordPress come in to play, the browser needs to establish a connection with the server over HTTPS by connecting, performing an SSL handshake, exchanging (and verifying) certificates, and only after all that is done, will the browser issue the HTTP request that tells the server what resources it is looking for.
Because of that, no .htaccess or WordPress plugin is going to be able to redirect the user without them establishing a secure session.
Of course if you install a self-signed certificate, the user is going to be presented with a warning before any of this happens. If you by chance (which doesn’t seem to be the cast) had been sending Strict Transport Security headers over https, then previous visitors’ browsers may not even allow them to connect over HTTP.
If you want to redirect HTTPS traffic to HTTP, unfortunately you are going to have to acquire a valid certificate and redirect using .htaccess or some PHP code as you are.
If you’re looking for certificates that are trusted by a majority of browsers without paying, you can get a free certificate from Let’s Encrypt.
Bottom line, if you want to seamlessly redirect HTTPS traffic to HTTP without any warning messages, you need to install another SSL certificate from a trusted CA.
Here is an alternative solution you can use if you don’t want to edit
.htaccess
:You can place this at the bottom of your theme
functions.php
Expanding on @HigherCoding ‘s answer and @MrWhite ‘s comment, to get a PHP function to do this on a site where the
https
port exists but the ssl certification is invalid, expired or non-existent:This worked on my site in
functions.php
and was a combination of these two sources: Source 1 and Source 2.As @drew010 pointed out – this will still not prevent a scary prompt for users who type in
https
as part of your URL. But it will redirect them tohttp
if they happen to click through the scary prompt, which is unlikely. It seems that getting an SSL certificate is likely the best option for this reason, for general security and for increased Google ranking now & in the future.The htaccess way is simple especially if you don’t have access to admin area in WordPress.
Just paste this below RewriteCond %{HTTPS} on
in addition to your lines please try to add these lines in wp-config.php
hopefully, your error will resolve
This disables https completely
This leaves The HTTPS enabled and then uses server VARIABLES to redirect all pages to HTTP:
Hope this helps you….