# Enable URL rewriting
RewriteEngine On

# ==============================
# 0. FORCE REMOVAL of "noindex"
# ==============================
<IfModule mod_headers.c>
    Header unset X-Robots-Tag
</IfModule>

# ==============================
# 1. Force HTTPS and www (Standard Redirect)
# ==============================
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.swarnavahini\.lk$ [NC]
RewriteRule ^(.*)$ https://www.swarnavahini.lk/$1 [L,R=301]

# ==============================
# 2. Serve robots.txt & sitemap.xml dynamically
# ==============================
RewriteRule ^robots\.txt$ robots.php [L]
RewriteRule ^sitemap\.xml$ sitemap.php [L]

# ==============================
# 3. EXPLICITLY ALLOW ACCESS TO PAGES
# This ensures no weird server rules block your PHP files
# ==============================
<FilesMatch "\.php$">
    <IfModule mod_authz_core.c>
        Require all granted
    </IfModule>
</FilesMatch>

# ==============================
# 4. Security: prevent access to hidden files (.htaccess, .git, etc.)
# ==============================
<FilesMatch "^\..*">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
</FilesMatch>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
