# Patel E-Mitra & Aadhaar Seva Kendra CMS
# Apache Configuration
# Enable Rewrite Engine
RewriteEngine On
# Redirect to HTTPS (uncomment if you have SSL)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Remove .php extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# Force trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
# Security Headers
# Prevent clickjacking
Header always append X-Frame-Options DENY
# Prevent MIME type sniffing
Header set X-Content-Type-Options "nosniff"
# Enable XSS protection
Header set X-XSS-Protection "1; mode=block"
# Referrer Policy
Header set Referrer-Policy "strict-origin-when-cross-origin"
# Protect sensitive files
Order allow,deny
Deny from all
Order allow,deny
Deny from all
# Protect config directory
RewriteRule ^config/ - [F,L]
# Protect includes directory
RewriteRule ^includes/ - [F,L]
# Protect database directory
RewriteRule ^database/ - [F,L]
# Disable directory browsing
Options -Indexes
# Set default charset
AddDefaultCharset UTF-8
# Enable compression
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
# Browser Caching
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Custom Error Pages
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
ErrorDocument 500 /500.php
# PHP Settings
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_execution_time 300
php_value max_input_time 300