# VNC India website. Requires Apache or LiteSpeed with .htaccess enabled (AllowOverride All).

Options -Indexes
DirectoryIndex index.php
ErrorDocument 404 /404.php
ErrorDocument 403 /404.php

# Clean URLs: /donate serves donate.php (the site links to pages without ".php")
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Send http:// to https:// (comment out until an SSL certificate is installed)
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP:X-Forwarded-Proto} !=https
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^([A-Za-z0-9_-]+)/?$ $1.php [L]
</IfModule>

# Block config, logs, SQL dumps and notes from the web
<FilesMatch "^(config\.php|config\.sample\.php|error_log|.*\.(log|sql|md|bak|old|orig|swp|ini|lock))$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

# Block hidden files such as .git or .env
<FilesMatch "^\.">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

# The PHPMailer library is only included by the site's own code
<IfModule mod_rewrite.c>
    RewriteRule ^PHPMailer/ - [F,L]
</IfModule>

# Basic security headers
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
