Magento installation redirect loop

Magento installation redirect loop

August 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento installation redirect loop

Resolving the Magento Installation Redirect Loop Issue

If you’re facing a redirect loop error during the installation of Magento on your VPS server using Nginx and php-fpm, don’t worry—you’ve come to the right place. In this post, we’ll troubleshoot the issue step-by-step and provide a practical solution.

Common Causes for the Redirect Loop Issue

Before diving into the fix, let’s identify some common reasons behind this problem:

  1. Incorrect Nginx Configuration: A misconfigured Nginx setup can cause Magento to redirect indefinitely.
  2. Missing or Incorrect .htaccess File: The .htaccess file plays a crucial role in routing requests. If it’s missing or incorrectly configured, you’ll encounter the redirect loop error.

Step-by-Step Solution

Check Your Nginx Configuration

Ensure your Nginx configuration is set up correctly. Here’s what your main server block should look like:

server {
    // ...
    location / {
        index index.php;
        try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d; ## Assume all files are cachable
    }

    # ... rest of your configuration ...

    location @handler { ## Magento uses a common front handler
        rewrite / /index.php;
    }

    # ... rest of your configuration ...
}

Verify the .htaccess File

Navigate to the root directory of your Magento installation (public_html in most cases). You should see an .htaccess file. If it’s missing, create one with the following content:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteRule ^index.php/ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

Check Ownership and Permissions

The web server (Nginx in your case) needs read permissions for the Magento files. Ensure that the ownership is set correctly:

chown -R www-data:www-data /home/mydomain/public_html

Grant appropriate permissions to the directories:

find /home/mydomain/public_html/ -type d -exec chmod 755 {} \;

Enable PHP as a FastCGI Server

In your Nginx configuration, make sure you have the following block enabled for handling .php files:

location ~* ^(.+\.php)($|/) {
    # ...
    fastcgi_pass   unix:/var/run/mydomain_fpm.sock;
    # ...
}

Enable Error Logging

If all else fails, enable error logging in Nginx to pinpoint the exact issue:

error_log /home/mydomain/_logs/error.log debug;

Conclusion

When dealing with a Magento installation redirect loop, always double-check your Nginx configuration and ensure that the necessary files (.htaccess) are present. Adjusting permissions and enabling proper PHP handling through FastCGI should resolve most issues.

Remember to follow best practices for configuring your server environment to avoid such problems in the future:

  • Regularly update your Magento installation and dependencies.
  • Monitor performance using tools like New Relic or Datadog.
  • Keep an eye on error logs for early detection of any potential problems.

If you’re still facing issues, don’t hesitate to reach out to our expert team at Laravel Company. We’d be happy to help!

Indexing API Configuration Errors

Our network