DirectoryIndex index.php
RewriteEngine On

# Never expose application internals or managed storage through the web root.
RewriteRule ^(?:app|config|database|handlers|modules|resources|storage|tools)(?:/|$) - [F,L,NC]
RewriteRule (^|/)\.(?!well-known(?:/|$)) - [F,L]

# Keep physical public files, API endpoints, installer entry points, and assets working normally.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Preserve established flat PHP URLs while loading grouped module routes.
RewriteRule ^([A-Za-z0-9_-]+)\.php$ route.php?route=$1 [QSA,L]

# Clean DentalCare slugs, for example /patients, /billing, /website-pages.
RewriteRule ^([A-Za-z0-9_-]+)/?$ route.php?slug=$1 [QSA,L]
