# PH33 (ph33bet.ph) - Apache & OpenLiteSpeed Technical SEO Directives

# 1. Enable Rewrite Engine
RewriteEngine On
RewriteBase /

# 2. Force HTTPS & Canonical Domain
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.ph33bet\.ph$ [NC]
RewriteRule ^(.*)$ https://ph33bet.ph/$1 [R=301,L]

# 3. Security Headers
<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set X-XSS-Protection "1; mode=block"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>

# 4. Browser Caching & Compression (WebP, CSS, JS)
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType application/xml "access plus 1 day"
  ExpiresByType text/xml "access plus 1 day"
</IfModule>

# 5. Custom 404 Error Handler
ErrorDocument 404 /404.html

# 6. Enforce 301 Permanent Redirect on Legacy / Broken URLs
# Route non-existent URLs to homepage with 301 Permanent Redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/404\.html$
RewriteCond %{REQUEST_URI} !^/assets/
RewriteCond %{REQUEST_URI} !^/styles/
RewriteCond %{REQUEST_URI} !^/scripts/
RewriteRule ^(.*)$ / [R=301,L]
