From 2e9fbe53610618fa276206632367f0f15794e1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Assun=C3=A7=C3=A3o?= Date: Mon, 11 May 2026 20:59:04 -0300 Subject: [PATCH] =?UTF-8?q?Configura=20.htaccess=20para=20p=C3=A1gina=20n?= =?UTF-8?q?=C3=A3o=20encontrada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .htaccess | 14 ++++++++++++-- public/notfound.php | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 public/notfound.php diff --git a/.htaccess b/.htaccess index 75f8982..b323a24 100644 --- a/.htaccess +++ b/.htaccess @@ -1,9 +1,19 @@ RewriteEngine On -# Impede que acessem pastas confidenciais (opcional, dependendo da estrutura) +# 1. Define a página de erro 404 personalizada na nova pasta +ErrorDocument 404 /public/notfound.php + +# 2. Protege pastas de sistema, mas permite acesso à pasta public +# Bloqueia src, config e vendor RewriteRule ^(src|config|vendor)/ - [F,L] -# Se o arquivo ou diretório não existir fisicamente, manda para o index.php +# 3. Regra do Roteador (Front Controller) +# Se o arquivo ou diretório solicitado não existir fisicamente... RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d + +# ...E não for a própria página de erro (para evitar loops) +RewriteCond %{REQUEST_URI} !^/public/notfound.php + +# Envia a requisição para o index.php RewriteRule ^(.*)$ index.php [QSA,L] \ No newline at end of file diff --git a/public/notfound.php b/public/notfound.php new file mode 100644 index 0000000..c02730a --- /dev/null +++ b/public/notfound.php @@ -0,0 +1 @@ +Não encontrado \ No newline at end of file