I'm trying to redirect all HTTP requests to HTTPS and all www to non-www URLs.
That is,
- http://example.net to https://example.net
- http://www.example.net to https://example.net
- http://www.example.net to https://example.net
- https://www.example.net to https://example.net
I was successfully able to redirect URL conditions (1, 2 & 3) but the 4th redirect condition does not work, i.e. https://www.example.net to https://example.net.
I have an SSL certificate for both www and non-www URLs for my website. I'm currently using WordPress.
My .htaccess file contains the following code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]
I've tried many different redirect conditions but none worked.
I get the following error in Firefox:
An error occurred during a connection to www.example.net. Peer reports it experienced an internal error. Error code: SSL_ERROR_INTERNAL_ERROR_ALERT
What can I do to redirect the 4th URL condition?