Maxim Volkov2021-12-15 13:14:33
Apache HTTP Server
Maxim Volkov, 2021-12-15 13:14:33

After installing an SSL certificate and switching to HTTPS - error: The site redirected too many times. How to fix?

Site on Laravel on VDS server Debian 10 + Appache2. After installing SSL certificates and switching the site to HTTPS, an error occurs:
The site has redirected too many times. ERR_TOO_MANY_REDIRECTS

Host File


<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName site.ru
    ServerAlias www.site.ru
    ServerAdmin [email protected]
    DocumentRoot /var/www/site.ru/public

    <Directory /var/www/site.ru/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All

    ErrorLog ${APACHE_LOG_DIR}/site.ru-error.log
    CustomLog ${APACHE_LOG_DIR}/site.ru.log combined

SSLEngine on
SSLProtocol all -SSLv2

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/site.ru/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/site.ru/privkey.pem

<FilesMatch "\.(cgi|shtml|phtml|php)$">
  SSLOptions +StdEnvVars

RewriteEngine on
RewriteCond %{SERVER_NAME} =site.ru
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,NE,R=permanent]

Everything seems to be correct, in accordance with the instructions, but a cyclic redirect occurs. Perhaps during the configuration, where the server settings were set to HTTP, and now there is a cyclic redirect.

In judging by the messages on the network, the problem is widespread, but none of the proposed solutions helped.
  • I ask for help and advice - where to look?
  • What could be causing the problem and how to solve it?

PS I believe the cause of the error occurred during the installation of phpMyAdmin, which I installed according to one of the many instructions. PhpMyAdmin was successfully installed and working, but without a separate host, site.ru/phpmyadmin/ opens. Perhaps somewhere in the cofigs he indicated something ... That's what and where could it be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Maxim Volkov, 2021-12-16

All! Problem solved. Perhaps the information will be useful to someone.
The problem was in the features of the hosting where the VDS server was rented - Gino, they provide proxying and port forwarding enabled by default, supposedly for the convenience of users. Which can be simply disabled in the settings.

akelsey, 2021-12-15

It’s not very clear why the redirect is left in the ssl part, I would also understand it would redirect from https://www.site.ru to https://site.ru , and looking at the syntax, I see the logic of the following logic (I don’t pretend, guru module rewrite will be corrected) - if SERVER_NAME contains the string site.ru -> redirect to site.ru. (by the way, according to the documentation, the string with "additional syntax" must be quoted)

RewriteEngine on
RewriteCond %{SERVER_NAME} =site.ru
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI } [L,NE,R=permanent]

I would comment out all three lines and twitch Apache.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question