2
Have the following structure in . htaccess:
RewriteEngine On
RewriteRule ^www\/login\/?$ login/ [L,NC,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 404 www/errors/404.php
And the following folder structure:
/public_html
/www - Arquivos como index, editX, deleteX, updateX
/errors - Dentro tem 404.php, 500.php, 403...
I want any error that gives (404) either in within www, or out (in the top folder), like the person type:
1st
www.meusite.com.br/anythingThere is no such thing as
or
2nd
www.meusite.com.br/www/otherthere is no
are redirected to errors/404.php, and the URL would look similar to this, ALWAYS:
www.meusite.com.br/www/errors/404
How could I do that, because the way it is neither in 1 nor in the second is redirecting correctly, is simply showing a text:
www/errors/404.php
EDIT
Fixed error showing text instead of redirecting, but it is not applying the style. In the console these errors are generated:
GET https://www.meusite.com.br/www/wjhbdsbn 404 (Not Found)
GET https://www.meusite.com.br/assets/css/error.min.css
GET https://www.meusite.com.br/assets/css/font-awesome.min.css
My page 404.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<base href="https://www.meusite.com.br/" />
<title>Metta Contabilidade</title>
<link rel="stylesheet" href="../assets/css/error.min.css" />
<link rel="stylesheet" href="../assets/css/font-awesome.min.css" />
</head>
<body>
<div class="container">
<h1>404</h1>
<p align="center">Página não encontrada!</p>
<p align="center">Indica uma dificuldade em encontrar uma página (arquivo ou diretório) especificada na barra de endereço.</p>
</div><br>
<div align="center">
<a href="javascript:history.back()">
<i class="fa fa-arrow-circle-left" aria-hidden="true"></i> Voltar
</a><br><br>
<a href="../main.php">
<i class="fa fa-arrow-circle-left" aria-hidden="true"></i> Voltar para página inicial
</a>
</div>
</body>
</html>
Try to put a
/
beforewww/errors/404.php
. In the documentation says: "A local URL to redirect to (if the action Begins with a "/")".– Woss
Okay that worked. But my style is not showing, it is showing only the text. It redirects but only shows the text.Could you help me find why? @Andersoncarloswoss
– user312516
Put the absolute URL to the CSS files, not the relative one.
– Woss
Isn’t that what the <base href="meusite.com.br"> does? @Andersoncarloswoss
– user312516
Strip the
..
CSS, if the directory is at the root of the project...– KaduAmaral
Not at the root. @Kaduamaral
– user312516
This way it would be accessing CSS files outside the root directory, which makes no sense. Put something like
/www/assets/...
, or/assets/...
if the folder is at the project root.– Woss
It worked with the first option: /www/Assets/... Thank you so much for helping @Andersoncarloswoss
– user312516