# Kofi Farms — clean URLs (no .php, no "index" in path)
# If the site lives in a subfolder, set RewriteBase to that folder (e.g. /kofi-farms/)
RewriteEngine On
RewriteBase /kofi-farms/

# Security: block direct access to includes
RewriteRule ^includes/ - [F,L]

# Redirect /index and /index.php to site root (no "index" in URL)
RewriteCond %{THE_REQUEST} \s/+kofi-farms/index(\.php)?[\s?] [NC]
RewriteRule ^index(\.php)?$ /kofi-farms/ [R=301,L]

# Redirect visible .php URLs to extensionless equivalents
RewriteCond %{THE_REQUEST} \s/+kofi-farms/([^\s?]+)\.php[\s?] [NC]
RewriteRule ^([^\s?/]+)\.php$ /kofi-farms/$1 [R=301,L]

# Skip existing files and directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Homepage
RewriteRule ^$ index.php [L]

# Extensionless pages → .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ $1.php [L]
