# ============================================================
# NAVTCC SEO Tool — Security Rules
# Created by Jawad with help of AI
# ============================================================

# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Block direct access to config.php
<Files "config.php">
    Order Allow,Deny
    Deny from all
</Files>

# Block access to logs directory
<IfModule mod_rewrite.c>
    RewriteRule ^logs/ - [F,L]
</IfModule>

# Block direct access to includes/
<IfModule mod_rewrite.c>
    RewriteRule ^includes/ - [F,L]
</IfModule>

# API proxy - no restrictions needed, PHP handles its own security
# api.php validates class code, rate limits, and key format internally

# Hide server info
ServerSignature Off

# Disable directory listing
Options -Indexes

# Set 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"
</IfModule>

# PHP settings
<IfModule mod_php.c>
    php_flag display_errors Off
    php_flag log_errors On
</IfModule>
