have this .conf file to my website, but everytime it should redirect to 404 page it says file not found, however if it goes to a normal page it works always.
server {
listen 80;
server_name mywebsite.com;
client_max_body_size 50M;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /$1.php last;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME /var/www/html/$server_name$fastcgi_script_name;
}
error_page 404 /404.php;
location = /404.php {
internal;
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_param SCRIPT_FILENAME /var/www/html/$server_name/404.php;
}
}
i just dont know why it says file not found, when i open the file directly http://mywebsite.com/404.php it works just fine
http://mywebsite.com/404.php
works, but it shouldn't aslocation = /404.php
matches the URL but is markedinternal
. Usesudo nginx -T
(uppercaseT
) to view the entire configuration across all included files and ensure that the configuration appears as stated in your question. Also, check the access log and error log for any related messages.