Nginx: [error] rewrite or internal redirection cycle while internally redirecting to "/index.php" (500 Internal Server Error)
Nginx kept internally redirecting (more than 10 times), typically from a try_files or rewrite that points back to itself.
rewrite or internal redirection cycle while internally redirecting to "/index.php"[error] rewrite or internal redirection cycle while internally redirecting to500 Internal Server Error rewrite or internal redirection cyclerewrite or internal redirection cycle while processingnginx internal redirection cycle index.html Meaning
Common with try_files $uri $uri/ /index.php; when /index.php doesn't exist at the configured root, or an index directive loop. Check root path, that the file exists, and the order of location blocks (location ~ \.php$ must handle /index.php).
Common causes
/index.phpmissing under the configured rootrootpoints to the wrong directory- try_files fallback to a non-existing URI
- Rewrite rule that matches its own output
- Location for PHP not defined
⚡ Quick fix
- Verify
rootand thatindex.phpexists - Fix fallback:
try_files $uri $uri/ /index.php?$query_string;with a working PHP location - Avoid rewriting to a path matched by the same rule
Detailed fix by platform
Linux
sudo nginx -T | grep -nE "root|try_files|index"; ls -l /var/www/app/public/index.php
How to diagnose
- File — index.php exists?
- Root — Correct path?
- Location — PHP block?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 404 on all routes except home (public folder / .htaccess) Laravel on shared hosting: homepage works but every other route returns 404 Not Found
- 499 Client Closed Request / client prematurely closed connection Nginx: [info] client prematurely closed connection while reading response header from upstream / access log status 499
- AH00124: Request exceeded the limit of 10 internal redirects Apache: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary
Most viewed in Nginx / Apache
- nginx: [emerg] unknown directive Nginx: nginx: [emerg] unknown directive "x" in /etc/nginx/sites-enabled/x:12 — configuration file test failed
- upstream timed out Nginx: upstream timed out (110: Connection timed out) while reading response header from upstream
- AH00558 Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name
Other ways to find it
Where this error sits
Origin: Edge & web server. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026