The 404.html file exists, but only ErrorDocument doesn’t seem to apply. If you look at infinityfree.com in the administration tool, there is an error page, but it goes to that link.ㄹ
file:
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
# END WordPress
# BEGIN protect xmlrpc.php
# END protect xmlrpc.php
ErrorDocument 404 /404.html
ErrorDocument 403 /404.html
ErrorDocument 500 /500.html
ErrorDocument 503 /404.html
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{THE_REQUEST} \s/.*\.php [NC]
RewriteRule ^.*$ - [R=404,L]
ErrorDocument 404 /404.html
What role: .php brings up 404.html.Except for file extensions: only allowed when connecting with index.
Please put your code in code blocks next time. I edited your post, it was unreadable because half of the .htaccess file was being parsed as formatting.
Besides that, I the .htaccess code seems fine (except for the duplicate ErrorDocument 404 lines, but that won’t cause issues). Can you please explain what’s not working for you? A few things that would help:
This is exactly what I would expect your code to do, and seems like intended behavior. If this is not what you want to happen, what do you want to happen instead?
And again, please format your post. Don’t just dump your code in the post field and hit Reply, without checking the preview pane or see what was published. If you did, you would see that the code becomes unreadable.
Please note the following help text shown below the “Action” field in the client area error pages configuration tool:
If a full URL is specified (starting with http:// or https://), the visitor will be redirected to the URL. If a file path is given (starting with a slash), the provided file is returned.
By specifying your 404 page like this, the server will just show the contents of the 404.html, but not change the URL.
ErrorDocument 404 /404.html
If you want people to be redirected to the new URL, you should setup the .htaccess rule like this (replace the domain in the URL with your own of course):
ErrorDocument 404 http://example.com/404.html
As the text in the client area implies: you can use both, but what exactly you specify has different consequences.
I’m sorry, but I really don’t understand what you mean by this, what the current behavior is or what you would like the behavior to be. In short, I don’t understand the issue, and if I don’t understand the issue then I cannot help solve it.
You’re keep pointing out what you don’t want to happen, but I can’t help you if I don’t know what you do want to happen.
So I would like to ask you again to ask the questions I asked before:
Please answer these questions one by one using real URLs, not example dummy URLs.
I used it.
If 404 calls, I want to call index.php without going to the link below.
I blocked it when accessing as a file finalist. (e.g. .php)
And when accessing .php, 404 appears, but the problem is that you have to call it in /404.html format, not in link format, but you can’t call it.
I’m still having a lot of trouble making sense of your messages. I’m not sure if you tried to answer the three questions I asked, but if so, I don’t understand what part is supposed to answer which question. Please maybe format your post to clearly answer the questions one by one instead of working them into a message?
Am I correct to understand that this is what you want:
If the request has a certain path (e.g. http://example.com/about), and a matching PHP file exists with that name (e.g. about.php), then load that file.
If someone requests a PHP file specifically (e.g. http://example.com/about.php), then a 404 error page should be shown.
The 404 error page is loaded by the index.php script, and the URL should not change.
If so, I think the solution should be as simple as specifying ErrorDocument 404 /index.php.
Can you please tell me if I understood the desired situation correctly?
When accessing with the fail extension (e.g., php), it is marked as 404 as an example, and it is not processed as 404.html of the 404 mark shown in the diagram.
Copy the contents of this post, put it on the website, attach .php to the website, and access it.
I’m sorry, but again, I need you to write more clearly.
As far as I can tell, your code does exactly what it implies, and I see no reason to replicate it myself to confirm that it does.
But what is clear is that the code is not doing what you want it to do. I can help you update the code so it does do what you want, but again: I have no idea what the desired behavior is.
Again: please answer my three question. One by one. With real URLs. Please consider using a format like this: