Sometimes you get too many redirects error when you try to access a website or URL. This is often a result of conflicting redirects in your website, that result in a redirect loop, causing server to endlessly redirect visitors. This error can occur in all servers such as Apache, NGINX, etc. In this article, we will look how to fix too many redirects error in a website.
What causes too many redirects error in Website
You get too many redirects error when your browser keeps getting redirected from one URL to the next, in an endless loop. This can happen if there are conflicting redirects in your server configuration, or even database/code for that matter. This can also be a result of faulty plugins, themes and libraries. For example, you may have competing redirects on your site such that one redirects from www to non-www URL while the other redirects from non-www to www, resulting in a redirect loop.
How to Fix Too Many Redirects Error in Website
Here are the steps to fix too many redirects error in website.
1. Delete Browser Data
The simplest way to fix too many redirects error is to clear browser cache and try accessing the URL again. This is because sometimes the browser data may get corrupted or cookies may get outdated. In most browsers, you can do this by pressing ctrl+shift+del keys together. You will see a form, where you can select the data and cookies you want to delete.
Also Read : How to Fix 403 Access Forbidden Error
2. Disable Plugins
If you use a CMS like WordPress, Joomla, Drupal, Magento, etc. then buggy plugins are a common reason for redirect loops on websites. Disable all plugins on your website and enable them one-by-one.
Also, if you have recently updated a plugin, then rollback those updates to previous stable version.
Also Read : How to Backup Website in cPanel
3. Check URL Settings
If you use WordPress, then check the WordPress URL and Site URL values to ensure they are proper. Many a times, when we update these values, WordPress starts misbehaving and giving redirect loops.
If your website is located in default root folder /public_html/ then you can use the default domain http://www.example.com as both WordPress URL and Site URL. If it is located in a subfolder such as /public_html/blog/ then your WordPress and Site URLs need to be updated as http://www.example.com/blog.
If you get a redirect loop in WordPress, then you may not be able to access the admin page of your website. In such cases, you will need to update these values by editing the wp-config.php file in your WordPress folder.
Also Read : How to Remove Malware from Website
4. Check .htaccess File
.htaccess file is commonly used in Apache web server to redirect URLs. Certain misconfigurations can cause Apache to redirect website visitors endlessly in a loop.
Disable .htaccess and restart Apache server to see if it fixes the issue. If the issue is fixed, then investigate each redirect that you have configured in .htaccess file.
Here are some of the commonly used redirect configurations in .htaccess for your reference
- Redirect HTTP to HTTPs using .htaccess
- Redirect non-www to www using .htaccess
- Redirect www to non-www using .htaccess
5. Inspect URL
If you happen to get too many redirects error only one a single or a few URLs on your website, then inspect the server response code for it, to look for any redirection that may have been misconfigured. Also, look for any recent changes in its code and roll it back, to see if it fixes the issue.
Hopefully, the above article will help you fix too many redirect error on your website.