{
  "id": "nginx/rewrite-or-internal-redirection-cycle",
  "signature": "rewrite or internal redirection cycle while processing",
  "signature_zh": "处理时发生重写或内部重定向循环",
  "regex": "rewrite or internal redirection cycle while processing",
  "domain": "nginx",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A rewrite rule or try_files directive causes an infinite loop because the rewritten URI matches the same location block repeatedly.",
  "root_cause_type": "generic",
  "root_cause_zh": "重写规则或try_files指令导致无限循环，因为重写后的URI反复匹配同一个location块。",
  "versions": [
    {
      "version": "nginx 1.18.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.20.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.22.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.25.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Logging doesn't break the cycle; it only helps debug.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This prevents external access but may still cycle internally if rewrite triggers same location.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Timeouts don't affect rewrite loops; they are unrelated.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add a break flag to the rewrite rule: rewrite ^/old/(.*)$ /new/$1 break;",
      "success_rate": 0.85,
      "how": "Add a break flag to the rewrite rule: rewrite ^/old/(.*)$ /new/$1 break;",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a separate location for the target URI to avoid recursion: location /new/ { ... }",
      "success_rate": 0.9,
      "how": "Use a separate location for the target URI to avoid recursion: location /new/ { ... }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Replace rewrite with try_files and a named location: try_files $uri @fallback; location @fallback { ... }",
      "success_rate": 0.8,
      "how": "Replace rewrite with try_files and a named location: try_files $uri @fallback; location @fallback { ... }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在重写规则中添加break标志：rewrite ^/old/(.*)$ /new/$1 break;",
    "为目标URI使用单独的location以避免递归：location /new/ { ... }",
    "用try_files和命名location替换重写：try_files $uri @fallback; location @fallback { ... }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-03-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}