Too many redirects error after deleting cache directory under runtime

Hi, I’m pretty new to yii and, obviously, I’m making errors as I’m going on.

I wish to delete all files and folders under runtime/cache directory and my mistake was to delete the whole cache directory instead its content.
After that I recreated cache directory using mkdir cache, and give it 775 permissions via chmod, and lately assign it to the user www-data, so actually it has the following structure

drwxr-xr-x  2 www-data www-data 4096 Oct 25  2022 HTML
drwxrwxr-x  2 www-data www-data 4096 Mar 27 13:49 cache
drwxrwxr-x  2 www-data www-data 4096 Mar 27 14:05 logs

Apparently everything is fine but now I’m getting a redirect error when trying to browse the site. ERR_TOO_MANY_REDIRECTS

My site installation is using versions : * 2.0.48.1

Any idea on how to solve it?

I’ve found the solution to this issue in stackoverflow, and I’m posting it here for future reference.

Apparently sometimes if a yii2 error occurs It shows too many redirects error instead of internal server error (500), so enable debug mode from web/index.php (uncomment these two lines to see exactly what causes the problem):

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

In my case it was a 500 error fired by this line 'rotateByDay' => true, added to config.php in log / targets array.

After removing this line the loop error was gone.

1 Like