Question
Can i can return 404 if file not exists?
Hello can i return 404 or 403 if anyone try to open /?a=b AND 1=1
My vhost is:
server {
listen 80;
listen [::]:80;
server_name mysite.com www.mysite.com;
root /var/www/mysite.com/public_html;
index index.php;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
root /var/www/mysite.com/public_html;
index index.php index.html index.htm index.nginx-debian.html;
server_name mysite.com www.mysite.com;
error_page 403 https://mysite.com/dead.html;
location = /dead.html {
allow all;
}
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 240;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\. {
deny all;
}
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×