I have added .htaccess
https
redirect from www
to non-www
with:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{HTTPS}s ^on(s)|off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L]
</IfModule>`
When I visit my domain, the following redirects happen without any problem:
→
→
But when I visit my domain as or
, my domain does not redirect and shows the error code:
SSL_ERROR_INTERNAL_ERROR_ALERT
(in Firefox) or ERR_SSL_PROTOCOL_ERROR
(in Chrome)
I have used WordPress and the plugin Really Simple SSL.
Any idea on how to fix my error?
I have added .htaccess
https
redirect from www
to non-www
with:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{HTTPS}s ^on(s)|off
RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$
RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L]
</IfModule>`
When I visit my domain, the following redirects happen without any problem:
http://www.example → http://example
http://www.example/abc → http://example/abc
But when I visit my domain as https://www.example
or https://www.example/abs
, my domain does not redirect and shows the error code: SSL_ERROR_INTERNAL_ERROR_ALERT
(in Firefox) or ERR_SSL_PROTOCOL_ERROR
(in Chrome)
I have used WordPress and the plugin Really Simple SSL.
Any idea on how to fix my error?
Share Improve this question edited Feb 11, 2017 at 5:01 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Feb 11, 2017 at 1:52 DinhTvDinhTv 771 gold badge3 silver badges11 bronze badges 3 |1 Answer
Reset to default 8Before I give you the CODE, let me explain a few points:
Point 1:
It's better if you only allow https
links. Mixing http
& https
for the same content breaks the security added by https
. With http
, you can never be sure that your visitors are shown the same page you are providing from your server.
Point 2:
Search engines consider http
& https
sites to be different sites, even when the domain is the same. So if not set up properly, you may get duplicate penalty. So it's recommended to go https
all the way for better SEO as well.
Point 3:
Even with proper .htaccess
CODE, you may get the same error if SSL is not set up properly. So after you change the .htaccess
CODE, it's better to test your SSL setup against standards. You may use tool such as this.
Recommended CODE:
Based on the points above, following is the CODE you may use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} =off [OR]
RewriteCond %{HTTP_HOST} !^example\$
RewriteRule ^(.*)$ "https://example/$1" [R=301,L]
# remaining htaccess mod_rewrite CODE for WordPress
</IfModule>
This will do the following example redirects:
http://www.example/ → https://example/
http://www.example/abc → https://example/abc
https://www.example/ → https://example/
https://www.example/abc → https://example/abc
# Additionally, even if your site is reachable by IP or
# some other domains or subdomains, this CODE will fix that too
http://Your_Server_IP/abc → https://example/abc
http://sub-dmoani.example/abc → https://example/abc
http://www.other-domain/abc → https://example/abc
Not Recommended CODE:
If for some reason, you don't want to follow the above recommendation & still want to allow both http
and https
, you may use the following CODE (based on this answer):
<IfModule mod_rewrite.c>
RewriteEngine On
# set protocol variable
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=proto:https]
RewriteCond %{HTTPS} =off
RewriteRule ^(.*)$ - [env=proto:http]
RewriteCond %{HTTP_HOST} !^example\$
RewriteRule ^(.*)$ "%{ENV:proto}://example/$1" [R=301,L]
# remaining htaccess mod_rewrite CODE for WordPress
</IfModule>
This will do the following example redirects:
http://www.example/ → http://example/
http://www.example/abc → http://example/abc
https://www.example/ → https://example/
https://www.example/abc → https://example/abc
http
requests to go tohttps
? – Fayaz Commented Feb 11, 2017 at 2:20