# Disable directory listing Options -Indexes # Block direct HTTP access to sensitive files Require all denied Require all denied Require all denied # Belt-and-braces: block any dotfile path component (except /.well-known) RewriteEngine On RewriteRule "(^|/)\.(?!well-known)" - [F,L] # A raiz web é o repositório inteiro, por isso fecha-se o que não é página: # - parciais (_form.php e afins) só se incluem, nunca se pedem; # - PHP soltos do platform-tools: só api/ e backups/ (auto-chamada com token) # são endpoints; o resto é incluído pelas páginas de views/sysadmin/; # - documentação (*.md) não é para servir. RewriteRule "(^|/)_[^/]*\.php$" - [F,L] RewriteRule "^shared/platform-tools/[^/]+\.php$" - [F,L] RewriteRule "\.md$" - [F,L] # ── Headers de segurança ───────────────────────────────────────────────────── # A CSP não restringe scripts ainda (o site tem scripts inline e incorporações # da Google); fecha o que não parte nada: quem pode meter o site num iframe, # , plugins e para onde os formulários podem enviar. Header always set X-Content-Type-Options "nosniff" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set X-Frame-Options "SAMEORIGIN" Header always set Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=()" Header always set Content-Security-Policy "frame-ancestors 'self'; base-uri 'self'; object-src 'none'; form-action 'self' https://forms.zohopublic.eu" # ── Canonical host: force HTTPS + strip www ─────────────────────────────────── RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} off RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # ── Let static files and backoffice pass through untouched ───────────────────── RewriteRule ^views/ - [L] RewriteRule ^uploads/ - [L] RewriteRule ^site/assets/ - [L] RewriteRule ^assets/ - [L] # ── Friendly URLs ───────────────────────────────────────────────────────────── RewriteRule ^home/?$ site/index.php [L] RewriteRule ^home/equipa/?$ site/equipa.php [L,QSA] RewriteRule ^home/modalidades/?$ site/modalidades.php [L,QSA] RewriteRule ^home/horario/?$ site/horario.php [L,QSA] RewriteRule ^home/contactos/?$ site/contactos.php [L,QSA] RewriteRule ^home/agendar/?$ site/agendar.php [L,QSA] RewriteRule ^home/inscricao/?$ site/inscricao.php [L,QSA] RewriteRule ^home/crossfit/?$ site/crossfit.php [L,QSA] RewriteRule ^home/privacidade/?$ site/privacidade.php [L,QSA] RewriteRule ^home/termos/?$ site/termos.php [L,QSA] RewriteRule ^evento/([a-zA-Z0-9-]+)/?$ site/evento.php?slug=$1 [L,QSA] # ── Ginásios: // (código postal da zona, ex.: /3070/) ───────────────── # Uma pasta por ginásio (Gestão → Ginásios); pastas desconhecidas ou por publicar # dão 404 no PHP. Reais ficheiros/pastas têm prioridade. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9][a-z0-9-]{1,19})/?$ site/index.php?gym=$1 [L,QSA] RewriteRule ^([a-z0-9][a-z0-9-]{1,19})/crossfit/?$ site/crossfit.php?gym=$1 [L,QSA] RewriteRule ^([a-z0-9][a-z0-9-]{1,19})/(agendar|inscricao)/?$ site/$2.php?gym=$1 [L,QSA] RewriteRule ^robots\.txt$ site/seo_files.php?f=robots [L] RewriteRule ^sitemap\.xml$ site/seo_files.php?f=sitemap [L] # Pass the Authorization header through to PHP RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] DirectoryIndex index.php # Página 404 própria (a do Apache mostrava a versão do servidor). ErrorDocument 404 /site/404.php