Provide 404 documentation with NGINX relative to the current path

I have the following server blocks:

server {
listen 80;
server_name petpal. co.il;
root /usr/share/nginx/petpal;
index index.php;
location / {
try_files $uri $uri/ @extensionless-php;< br /> }
location @extensionless-php {
rewrite ^(.*)$$1.php last;
}
location ~ \.php${
try_files $uri /notfound;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}< br />}

What changes do I need to make to make the 404 document display according to the user’s current directory, for example, in the directory “/en” it will display “/en/notfound” and the directory “/”. Show “/notfound”?

Maybe an if will work?

set $lang "";
if ($uri ~ "^/en/") {set $lang "en/"; }< br />try_files $uri /${lang}notfound;

Or, if you want a more general rule:

set $lang "" ;
if ($uri ~ "^/([az][az])/)") {set $lang "$1"; }
try_files $uri /${lang}notfound;

I have the following server blocks:

server {
listen 80;
server_name petpal.co.il;
root /usr/share/nginx/petpal;
index index.php;
location / {
try_files $uri $uri/ @extensionless-php ;
}
location @extensionless-php {
rewrite ^(.*)$$1.php last;
}
location ~ \.php${
try_files $uri /notfound;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

What changes do I need to make to display the 404 document according to the user’s current directory, for example, "/en/notfound" and directory "/" are displayed in the directory "/en" It will display "/notfo und"?

Maybe an if will work?

set $lang "";
if ($uri ~ "^/en/") {set $lang "en/"; }< br />try_files $uri /${lang}notfound;

Or, if you want a more general rule:

set $lang "" ;
if ($uri ~ "^/([az][az])/)") {set $lang "$1"; }
try_files $uri /${lang}notfound;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4663 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.