i have this .htaccess
file, but i need to want to have a 404 error page. but when i add ErrorDocument to it i do nothing. if i write localhost:8888/home/somepage-there-not-exist
.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
it's located in the root same with the app and public folder
Ind the public folder there are this too:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
I know the code coveret /something to files request, but when the file not exit it should get a 404 error.
It's from laravel's root .htaccess
after some i like some part of the framework, but i wanna make a code block there only is there to make the website secure, and not a framework (don't wanna invent the wheel again). But i still need it to understand urls that way because it make it SEO and open so there no rules are for the URL
So i have student laravel's code and figure out how it works, but this part about 404, 403 and so on.. is so complicated in laravel's and cross so maney files that you don't have a chance to understand the code and find out how laravel know when it's a 404 error.
UPDATE
I have found this ErrorDocument-VS-RewriteRule
after what i see i can use
RewriteRule ^(.*)$ - [L,R=404]
ErrorDocument 404 /errors/errors.php
thats kinda works, but not 100%. the ErrorDocument don't work when you are 2 steps in example: localhost/step1/step2
and it also broke it so when the site exist it still show the error page. i have try to set the code over and under the RewriteRule ^(.*)/$ /$1 [L,R=301]
Yes this project is maybe stupid but i do it for lerning
ErrorDocument
there... – KurbashErrorDocument
in it, and that dosen't help, thats why i ask – Langelorewrite
does? It makes no much sense to use both together – Kurbashlocalhost/home
ask for the filehome.php
but when you typelocalhost/users/profile
it should ask for a file in the folder users after profile.php – Langelo