Перенаправление было создано для возврата «404» и перехода в первый каталог URL, например:
foo.com.br/air/uknwfileerror
> foo.com.br/air
Но это не работает только для .php
расширения
foo.com.br/air/uknwfileerror.php
> foo.com.br/air
listen *:443;
server_name portal-dev.foo.com.br ;
root /var/www/novo;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 20m;
resolver 1.1.1.1;
set $proxy_foops_https 'https://proxy-portal-dev-stg.foo.com.br';
set $proxy_foops_http 'http://proxy-portal-dev-stg.foo.com.br';
ssl on;
ssl_certificate /etc/nginx/ssl/wildcard.crt;
ssl_certificate_key /etc/nginx/ssl/wildcard.key;
access_log /var/log/nginx/dev.foo.com.br.ssl.access.log;
error_log /var/log/nginx/dev.foo.com.br.ssl.error.log;
error_page 404 = @notfound;
location @notfound {
rewrite ^/([\w-]*)/.* https://$server_name/$1/ permanent;
}
add_header Access-Control-Allow-Origin '$http_origin';
add_header Access-Control-Allow-Headers 'origin, x-requested-with, content-type';
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Credentials 'true';
location = /portal/{
rewrite ^ https://$server_name/ permanent;
}
location /portal/ {
index index.php index.html index.htm;
try_files $uri $uri/ /portal/index.php?$args;
}
location ~ wp-login\.php$ {
allow all;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location / {
location ~* \.(jpg|jpeg|gif|bmp|ico|png|css|js|swf|woff)$ {
expires 7d;
access_log off;
}
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
fastcgi_intercept_errors on;
}
location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location /cas/ {
proxy_pass $proxy_foops_https;
proxy_set_header Host portal-dev.foo.com.br;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_set_header X_FORWARDED_PROTO https;
}
location /auth-service {
proxy_pass $proxy_foops_https;
proxy_set_header Host portal-dev.foo.com.br;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_set_header X_FORWARDED_PROTO https;
}
}
с использованием Curl -I
Я вижу, что он возвращает 301 с URL foo.com.br/air/uknwfileerror.php
, но с путем foo.com.br/air/uknwfileerror
возвращает только 200, и я загружаю домашнюю страницу.
Ожидается, что при вводе пути с 404, также возвращается к первому напечатанному блоку:
foo.com.br/air/uknwfileerror.php
> foo.com.br/air
foo.com.br/air/uknwfileerror
> foo.com.br/air