Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

https to http redirect

I have searched everywhere and still can't find any answers.

I'm trying to redirect eg: https://www.domain.com to http://www.domain.com

Currently I have a .htaccess file which includes:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^443$ [OR]
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

But I keep receiving the following error:

An error occurred during a connection to www.domain.com.
SSL received a record that exceeded the maximum permissible length.
(Error code: ssl_error_rx_record_too_long)...

Do I need to add anything to my vhost file for VirtualHost *:443? for domain.com - Apologies, quite new to this. Any help/direction would be greatly appreciated, thanks!

like image 337
williamsowen Avatar asked Jan 22 '26 03:01

williamsowen


1 Answers

You need to have fully working https vhost. Please paste here what you have in your vhost.

<VirtualHost IP:443>
    ServerName www.domain.com
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/www.domain.com.crt
    SSLCertificateKeyFile /etc/ssl/private/www.domain.key

    ReWriteEngine On
    RewriteRule (.*) http://www.domain.com%{REQUEST_URI}
</VirtualHost>

If you have the same vhost for http and https things can get messy. Btw your cert must have CNAME for www.domain.com or if you have wildcard *.domain.com. And one more thing, you don't need any RewriteCond here because you rewrite every https request.

like image 110
Uroš Avatar answered Jan 25 '26 07:01

Uroš



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!