Err_too_many_redirects

My website URL is:
abmsolucoes.cf

What I’m seeing is:
ERR_TOO_MANY_REDIRECTS

When trying to open my site, the message ERR_TOO_MANY_REDIRECTS occurs,
my .htaccess file is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ http://abmsolucoes.cf/index.php?url=$1 [QSA,L]
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

my index.php is:

<?php

session_start();

require 'config.php';

spl_autoload_register(function($class){

if(file_exists('controllers/'.$class.'.php')){

require 'controllers/'.$class.'.php';

}else if(file_exists('models/'.$class.'.php')){

require 'models/'.$class.'.php';

}else if(file_exists('core/'.$class.'.php')){

require 'core/'.$class.'.php';

}else{

header("Location: ".BASE_URL);

}

});

$c = new Core();

$c->run();

?>

Theres probably a misconfiguration in your .htaccess file that your ssl certificate doesn’t understand. Are you using Let’s encrypt?

Not

I checked your website, but the actual .htaccess file on it is different from what you shared here. And if I read the line correctly, it will cause any request which is sent over HTTP to be redirected to HTTP.

And that, of course, will cause a redirect loop.

What did you intend to achieve with the .htaccess rules currently there? If you could explain that, maybe we can help you find or write rules which do what you need?

3 Likes

I would like it to redirect to my index.php

Hmm, looking at your .htaccess rules, I think this might be the issue:

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

I think this should be:

RewriteRule ^(.+)$ /index.php?url=$1 [QSA,L]

If you don’t include the slash, the server may try to look for an index.php file in the directory you’re trying to access, rather than the one at the root of the website.

1 Like

I changed it, but it has the same error

I just checked your website, and I don’t think the .htaccess rules are the problem. Because even after I disabled all the rules, I still got a redirect error.

Can you please check whether your PHP code does any redirects? If so, those are likely responsible for the redirect loop issue?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.