# Enable rewriting
RewriteEngine On

# Let real files/folders pass through
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Map pretty URLs to physical files under /screens/<section>/
# e.g.  /admin/company-profile/branches.php  -> /admin/screens/company-profile/branches.php
RewriteRule ^([a-z0-9_-]+)/(.+\.php)$ screens/$1/$2 [L,QSA]

# (Optional) block direct public access to /screens/ to force pretty URLs
RewriteRule ^screens/ - [F,L]


# Pretty path without .php
#RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)$ screens/$1/$2.php [L,QSA]

# and keep the previous rule too if you want both to work


# Redirect all 404 (Not Found) errors to 404.php
ErrorDocument 404 /404.php
