# =========================================================
# UBS HRMS - Apache Configuration
# =========================================================

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ubs-hrms/

    # ---------------------------------------------------------
    # Block direct access to protected folders
    # ---------------------------------------------------------
    RewriteRule ^includes(/.*)?$  - [F,L]
    RewriteRule ^storage(/.*)?$   - [F,L]
    RewriteRule ^vendor(/.*)?$    - [F,L]
    RewriteRule ^config(/.*)?$    - [F,L]

    # ---------------------------------------------------------
    # Redirect .php URLs to clean URLs
    # ---------------------------------------------------------
    RewriteCond %{THE_REQUEST} \s/+ubs-hrms/(.+?)\.php[\s?] [NC]
    RewriteRule ^ /ubs-hrms/%1 [R=301,L]

    # ---------------------------------------------------------
    # Route clean URLs to the correct .php file
    # ---------------------------------------------------------
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.+?)/?$ $1.php [L]
</IfModule>

Options -Indexes
DirectoryIndex index.php

<FilesMatch "^(\.env|\.htaccess|\.htpasswd|composer\.(json|lock)|package(-lock)?\.json|README\.md|\.gitignore)$">
    Require all denied
</FilesMatch>

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
</IfModule>