# Funeral Care - URL and path stability
Options -Indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /funeral_a/

    # Redirect legacy /funeral/ URLs to /funeral_a/ (same host)
    RewriteCond %{REQUEST_URI} ^/funeral/(.*)$ [NC]
    RewriteRule ^ /funeral_a/%1 [R=301,L]

    # Remove trailing slashes from non-directory URLs
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [R=301,L]

    # Collapse duplicate slashes in the URL
    RewriteCond %{THE_REQUEST} \s/+([^\s?]*?)//+([^\s?]*)
    RewriteRule ^ %1/%2 [R=301,L]
</IfModule>

# Block direct web access to sensitive PHP includes
<FilesMatch "^(config|connection|db_schema|redirect|root)\.php$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
    </IfModule>
</FilesMatch>
