Answer the question
In order to leave comments, you need to log in
Why is 404 given to everything except index.php?
Hello.
I'm trying to deploy a site on DigitalOcean.
I set up nginx and php-fpm according to the manuals, index.php returns correctly, but there is a form on the page that sends an ajax request to the mail.php script, which lies next to index.php.
The problem is that instead of executing mail.php, nginx's 404 file not found is returned.
Here is my nginx config:
server {
listen 80;
listen [::]:80;
root /var/www/site.com/dist;
index index.html index.php index.htm index.nginx-debian.html;
server_name site.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Answer the question
In order to leave comments, you need to log in
Because you most likely have redirect rules in htaccess, but it is not processed. Check the location /, the error is most likely in the try_files line.
If there is htacess, then look at all sorts of online rule converters from it to nginx, if it is not there, then manually or through Google for your cms or framework
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question