# HTTPException: 308 Permanent Redirect: Redirect loop detected

- **ID:** `python/starlette-http-redirect-loop`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Starlette 应用中的重定向配置导致无限循环

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **检查并修复重定向逻辑** (90% success)
   ```
   # 确保不重定向到自身
if request.url.path != '/target':
    return RedirectResponse('/target')
   ```
2. **使用条件重定向避免循环** (85% success)
   ```
   if not request.cookies.get('redirected'):
    response = RedirectResponse('/target')
    response.set_cookie('redirected', '1')
    return response
   ```

## Dead Ends

- **增加重定向次数限制但未修复逻辑** — 最终仍会失败，且用户体验差 (70% fail)
- **删除所有重定向路由** — 可能破坏应用功能 (60% fail)
