# EXAMPLE ONLY. Verify AllowOverride/mod_rewrite/PHP handler and every filesystem path first.
# Place before existing static index handling in the verified PLOCAL virtual host or root rules.

RewriteEngine On

# Deny direct client requests for backend and non-public project documents.
RewriteCond %{THE_REQUEST} \s/+backend/ [NC,OR]
RewriteCond %{THE_REQUEST} \s/+(?:PLOCAL_[^?\s]*\.(?:txt|md)|deploy/|tools/|\.) [NC]
RewriteRule ^ - [R=404,L]

# Canonical trailing slashes; the original query string is preserved.
RewriteRule ^texas/dallas/plumbing$ /texas/dallas/plumbing/ [R=308,L,NE]
RewriteRule ^pro/(demo-aqualine-plumbing-dallas-tx|demo-blue-valve-plumbing-dallas-tx|demo-clear-route-plumbing-dallas-tx|demo-copper-junction-plumbing-dallas-tx|demo-plumbing-company-dallas-tx|demo-north-grid-plumbing-dallas-tx)$ /pro/$1/ [R=308,L,NE]

# Exact allowlist wins before DirectoryIndex/static resolution.
RewriteRule ^texas/dallas/plumbing/$ backend/public/index.php [L,QSA]
RewriteRule ^pro/(demo-aqualine-plumbing-dallas-tx|demo-blue-valve-plumbing-dallas-tx|demo-clear-route-plumbing-dallas-tx|demo-copper-junction-plumbing-dallas-tx|demo-plumbing-company-dallas-tx|demo-north-grid-plumbing-dallas-tx)/$ backend/public/index.php [L,QSA]

# /assets/ remains under the existing verified PLOCAL document root.
# Rollback: remove/disable only the four canonical/allowlist RewriteRule lines and reload Apache.
