# .htaccess file for IMS application on InfinityFree hosting

# Set the default character set
AddDefaultCharset UTF-8

# Set index.php as the default document
DirectoryIndex index.php

# Enable URL rewriting
RewriteEngine On

# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward it to index.php
RewriteRule . index.php [L]

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

# Disable directory browsing
Options -Indexes

# Protect config directory
<IfModule mod_rewrite.c>
RewriteRule ^config/.* index.php [L,R=301]
</IfModule>

# Set security headers
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
Header set X-Frame-Options "SAMEORIGIN"
</IfModule>

# PHP settings
<IfModule mod_php7.c>
php_value upload_max_filesize 55M
php_value post_max_size 60M
php_value memory_limit 256M
php_value max_execution_time 300
php_flag display_errors Off
php_flag log_errors On
</IfModule>