# BEGIN Moon Storefront SEO Discovery
# Managed by projects/storefront/deploy/install-root-seo-bridge.sh (called by the
# storefront AND website deploy scripts) — local rules outside this block are
# preserved on every release. robots.txt / sitemap.xml go to the neutral owner
# (website-seo-index: answers when the store OR the website is on; store-only output
# is the storefront's own); store chunks and merchant feeds stay on storefront-seo-index.
# [L], NOT [END]: the target is answered by /moon-erp-be/.htaccess (its own rewrite to
# index.php). [END] stops that later per-directory round, so every rule 404s — measured
# on moonui 2026-10-27 (WP7b), reverted within a minute.
# Every rule is GUARDED by the backend front controller at /moon-erp-be/ (a RewriteCond
# covers only the next rule): on a docroot without it (a MoonStack shim) the block is
# inert and the tenant's own robots.txt / Laravel's root routes answer.
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{DOCUMENT_ROOT}/moon-erp-be/index.php -f
  RewriteRule ^robots\.txt$ /moon-erp-be/website-seo-index/robots.txt [L]
  RewriteCond %{DOCUMENT_ROOT}/moon-erp-be/index.php -f
  RewriteRule ^sitemap\.xml$ /moon-erp-be/website-seo-index/sitemap.xml [L]
  RewriteCond %{DOCUMENT_ROOT}/moon-erp-be/index.php -f
  RewriteRule ^sitemap-site-([0-9]+)\.xml$ /moon-erp-be/website-seo-index/sitemap-site-$1.xml [L]
  RewriteCond %{DOCUMENT_ROOT}/moon-erp-be/index.php -f
  RewriteRule ^sitemap-(static|categories|pages|products)-([0-9]+)\.xml$ /moon-erp-be/storefront-seo-index/sitemap-$1-$2.xml [L]
  RewriteCond %{DOCUMENT_ROOT}/moon-erp-be/index.php -f
  RewriteRule ^merchant-(ar|en)\.xml$ /moon-erp-be/storefront-seo-index/merchant-$1.xml [L]
</IfModule>
# END Moon Storefront SEO Discovery
