Estoy intentando configurar páginas 404 dinámicas para poder mantener la URL del contenido faltante, mostrarla en la página 404 y mantener consistente la plantilla de mi sitio.
Aquí está la configuración de mi sitio:
server {
listen 80;
server_name www.example.com;
client_max_body_size 1024M;
client_body_buffer_size 512M;
if ($http_host !~* "^www\.example\.com"){
set $rule_0 1$rule_0;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ http://www.example.com/$1 permanent;
break;
}
rewrite ^/([a-zA-Z0-9-_]+)$ /profile.php?url=$1 last;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;
}
location / {
root /var/www/html/example.com;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /var/www/html/example.com;
fastcgi_pass example_fast_cgi;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/example.com$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 = @handler;
location @handler {
root /var/www/html/example.com;
try_files $uri /404.php = 404;
}
location ~ /\.ht {
deny all;
}
}
Esto parece estar casi ahí, pero cualquier página que debería ver la página 404 recibe un aviso para descargar el archivo PHP sin procesar. Agregar los parámetros de FastCGI no hizo nada.