F
F
FronzZ2021-01-11 15:01:02
htaccess
FronzZ, 2021-01-11 15:01:02

How to correct the code so that my page with 404 not found, and not the standard one, comes out on an error?

Hello! If someone understands htaccess. Can you tell me how to change the code below so that with the rules below, my 404 page always comes out? At the moment, a standard 404 page is displayed for these rules, and only when these rules do not work is mine ...: As I understand it, the whole thing is in this line: RewriteRule .* - [L,R=404], but how to fix it so that everything works, I don't understand.

ErrorDocument 404 /err404.php
RewriteEngine on
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
# RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$" [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
RewriteRule .* - [L,R=404]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-01-11
@FronzZ

RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]

Change to:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule \.php - [L,R=404]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question