Too Many Redirects Fix

User
after adding https to site url admin shows error too many redirect wordpress
Assistant
The "too many redirects" error in WordPress after enabling HTTPS typically occurs due to misconfiguration in the WordPress site URL, `.htaccess`, or server settings. Here’s how to troubleshoot and resolve this:

### 1. **Update WordPress Site URL**
Ensure the site URL and WordPress URL are correctly set to use HTTPS.

#### a) Update via Admin Panel:
– Go to **Settings > General**.
– Update both **WordPress Address (URL)** and **Site Address (URL)** to start with `https://`.

#### b) Update via `wp-config.php`:
If you can't access the admin panel:
1. Open the `wp-config.php` file in your WordPress root directory.
2. Add these lines:

define('WP_HOME', 'https://yourdomain.com');
   define('WP_SITEURL', 'https://yourdomain.com');

### 2. **Check `.htaccess` File**
Ensure the `.htaccess` file has proper redirection rules. Here’s a basic setup for WordPress with HTTPS:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

### 3. **Check Plugin Conflicts**
A plugin conflict can also cause redirect loops:
– Temporarily disable all plugins by renaming the `wp-content/plugins` folder.
– If the issue resolves, re-enable plugins one by one to identify the culprit.

### 4. **Clear Cache**
– Clear your browser cache.
– If you’re using a caching plugin (e.g., WP Super Cache, W3 Total Cache), clear its cache and disable it temporarily.
– If your server uses caching (e.g., Nginx or Varnish), clear the server cache.

### 5. **Server Configuration**
#### a) Nginx:
Ensure HTTPS redirection is properly configured. Add the following to your Nginx configuration:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    return 301 https://yourdomain.com$request_uri;
}

#### b) Apache:
Ensure the `mod_rewrite` module is enabled:

sudo a2enmod rewrite
sudo systemctl restart apache2

### 6. **Cloudflare or Reverse Proxy**
If you're using a CDN or reverse proxy like Cloudflare:
– Ensure SSL is set to "Full" or "Full (Strict)" in the Cloudflare dashboard.
– Avoid enabling conflicting HTTPS redirection in both Cloudflare and WordPress.

### 7. **Debug the Issue**
If the issue persists, enable WordPress debugging:
1. Add this to `wp-config.php`:

define('WP_DEBUG', true);
   define('WP_DEBUG_LOG', true);

2. Check the `wp-content/debug.log` file for errors.

### 8. **Test and Verify**
– Use [Redirect Checker](https://www.redirect-checker.org/) to identify the redirect loop's origin.
– Test the site on an incognito browser or different device.

If the issue remains unresolved, share your `.htaccess`, server configuration, or any custom redirection settings you’ve applied for more specific guidance.

Leave a Comment

Your email address will not be published. Required fields are marked *