deepinit 生成的子目录级 AGENTS.md 文件,帮助 AI agents 理解各功能模块: - docs/config/: advanced, basic, caching, load-balancing, lua, rewriting, security, ssl - docs/lua/: api-gateway, authentication, caching, dynamic-routing, logging-monitoring, middleware, rate-limiting, websocket Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1.1 KiB
1.1 KiB
rewriting
Purpose
URL 重写配置示例目录,包含 rewrite 规则、重定向等 URL 处理配置。
Key Files
| File | Description |
|---|---|
rewrite-rules.conf |
URL 重写规则:正则匹配、变量替换、内部重定向 |
redirect.conf |
重定向配置:301/302 跳转、域名迁移 |
For AI Agents
Working In This Directory
- rewrite 使用正则表达式匹配 URL
- last 表示重写后重新匹配 location
- break 表示重写后直接处理,不再匹配
- redirect 返回 302,permanent 返回 301
Testing Requirements
- 重写规则通过单元测试验证
- 测试正则匹配和变量替换正确性
Common Patterns
- 正则捕获:
rewrite ^/user/(\d+)$ /profile?id=$1 last - 域名迁移:
return 301 https://new.domain.com$request_uri - HTTP 转 HTTPS:
return 301 https://$host$request_uri
Dependencies
Internal
../../../internal/middleware/rewrite/- 重写中间件实现../../../internal/handler/- 请求处理器