# 动态 robots.txt / sitemap
rewrite ^/robots\.txt$ /index.php last;
rewrite ^/ads\.txt$ /index.php?__ads_txt=1 last;
rewrite ^/sitemap\.xml$ /index.php?slug=sitemap.xml last;
rewrite ^/sitemap\.html$ /index.php?slug=sitemap.html last;

# 真实文件存在则直接返回，不走伪静态重写（如 /document/*.html）
if (-f $request_filename) {
    break;
}

# 首页：未生成静态时走 PHP 动态入口
rewrite ^/$ /index.php last;

# 文章详情页：/wps/wps-2.html
rewrite ^/(.+)\.html$ /index.php?slug=$1 last;

# 搜索页：/search?q=关键词
rewrite ^/search/?$ /index.php?slug=search last;

# 首页分页：/page/2/
rewrite ^/page/(\d+)/?$ /index.php?slug=index/page/$1 last;

# 文章聚合页：/articles/
rewrite ^/articles/?$ /index.php?slug=articles last;

# 标签页：/tag/fareyingdui/
rewrite ^/tag/([a-zA-Z0-9\-_]+)/?$ /index.php?slug=tag/$1 last;

# 标签分页：/tag/fareyingdui/page/2/
rewrite ^/tag/([a-zA-Z0-9\-_]+)/page/(\d+)/?$ /index.php?slug=tag/$1/page/$2 last;

# 栏目页分页：/tiyu/page/2/
rewrite ^/([a-zA-Z0-9\-_]+)/page/(\d+)/?$ /index.php?slug=$1/page/$2 last;

# 栏目页：/tiyu/
rewrite ^/([a-zA-Z0-9\-_]+)/?$ /index.php?slug=$1 last;
