August 2017
Intermediate to advanced
278 pages
8h 53m
English
In order to convert the 404 requests into arguments, here's our server directive:
server {
listen 80;
server_name demosite.nginxcookbook.com;
access_log /var/log/nginx/demosite.access.log combined;
index index.php;
root /var/www/vhosts/demosite;
error_page 404 @404page;
location @404page {
try_files $uri $uri/ /search.php?uri=$uri&$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
try_files $uri $uri/ /search.php?uri=$uri&$args;
}
}
In this server block, we've assumed that the site uses PHP, but static files with a search file just for the 404 errors will also work.
Read now
Unlock full access