# NID System .htaccess
# Basic configuration for NID RECHARGE website

# Set PHP timezone to Bangladesh
php_value date.timezone "Asia/Dhaka"

# Enable rewrite engine
RewriteEngine On

# Set default character set
AddDefaultCharset UTF-8

# Set MIME types
<IfModule mod_mime.c>
    AddType application/javascript .js
    AddType text/javascript .js
    AddType text/css .css
    AddType application/json .json
</IfModule>

# Handle maintenance mode (if enabled)
# This will be managed by the maintenance system

# Basic security headers
<IfModule mod_headers.c>
    # Set X-Content-Type-Options for all files except JS
    <FilesMatch "\.(html|htm|php|css)$">
        Header always set X-Content-Type-Options nosniff
    </FilesMatch>
    
    Header always set X-Frame-Options DENY
    Header always set X-XSS-Protection "1; mode=block"
    
    # Cache control for CSS files
    <FilesMatch "\.css$">
        Header set Cache-Control "max-age=3600, must-revalidate"
    </FilesMatch>
    
    # Set proper MIME type for JavaScript files
    <FilesMatch "\.js$">
        Header set Content-Type "application/javascript"
        Header unset X-Content-Type-Options
    </FilesMatch>
</IfModule>

# Prevent access to sensitive files
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

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

# Enable compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

# Cache control for static assets
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType text/css "access plus 1 hour"
    ExpiresByType application/javascript "access plus 1 hour"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/ico "access plus 1 year"
    ExpiresByType image/icon "access plus 1 year"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>

# Disable directory listing in the /views/ directory
<IfModule mod_autoindex.c>
    Options -Indexes
</IfModule>

# Custom 403 error page
ErrorDocument 403 /403.html

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