# The host applies a 24-hour Cache-Control to every response by default (confirmed via
# curl: even the static root "coming soon" page gets the same header) — fine for that
# page, but it means every dynamically-rendered blog page (which should reflect content/
# settings changes immediately) can appear stuck on stale content in a visitor's browser
# for up to a day. Scoped to .php responses only so uploaded images/CSS/JS under this
# folder keep whatever caching benefit the host's default already gives them.
<IfModule mod_headers.c>
    <FilesMatch "\.php$">
        Header set Cache-Control "no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header unset Expires
    </FilesMatch>
</IfModule>

RewriteEngine On

# Only rewrite requests that don't match a real file or directory
# (so /admin/, /uploads/, /includes/, /lang/, actual .php files, etc. are left alone).
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# /sitemap.xml -> sitemap.php (generated live from published posts, no file on disk)
RewriteRule ^sitemap\.xml$ sitemap.php [L]

# /posts.json -> posts-json.php (read-only published-posts list API, opt-in via Settings)
RewriteRule ^posts\.json$ posts-json.php [L]

# /posts/post-slug.json -> post-json.php?slug=post-slug (single published post, full content)
RewriteRule ^posts/([a-z0-9-]+)\.json$ post-json.php?slug=$1 [L,QSA]

# /category/category-slug -> category.php?slug=category-slug
RewriteRule ^category/([a-z0-9-]+)/?$ category.php?slug=$1 [L,QSA]

# /tag/tag-slug -> tag.php?slug=tag-slug
RewriteRule ^tag/([a-z0-9-]+)/?$ tag.php?slug=$1 [L,QSA]

# /post-slug -> post.php?slug=post-slug
RewriteRule ^([a-z0-9-]+)/?$ post.php?slug=$1 [L,QSA]
