/en/content/images/image.jpg
нужно редиректить на /content/images/image.jpg
. Написал (код ниже), но почему-то не работает, что я делаю не так?location ~ ^/en/content/(.*)$ {
proxy_pass $scheme://mydomain/content/$1;
}
server {
listen [мой_ip]:443 ssl http2;
server_name [мойдомен] www.[мойдомен];
root /home/admin/web/[мойдомен]/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/[мойдомен].log combined;
access_log /var/log/nginx/domains/[мойдомен].bytes bytes;
error_log /var/log/nginx/domains/[мойдомен].error.log error;
ssl_certificate /home/admin/conf/web/[мойдомен]/ssl/[мойдомен].pem;
ssl_certificate_key /home/admin/conf/web/[мойдомен]/ssl/[мойдомен].key;
ssl_stapling on;
ssl_stapling_verify on;
include /home/admin/conf/web/[мойдомен]/nginx.hsts.conf*;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
fastcgi_hide_header "Set-Cookie";
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/run/php/php7.3-fpm-[мойдомен].sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
# WebP Express rules
# --------------------
location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
add_header Vary Accept;
expires 365d;
if ($http_accept !~* "webp"){
break;
}
try_files
/wp-content/webp-express/webp-images/doc-root/$uri.webp
$uri.webp
/wp-content/plugins/webp-express/wod/webp-on-demand.php?xsource=x$request_filename&wp-content=wp-content
;
}
# Route requests for non-existing webps to the converter
location ~* ^/?wp-content/.*\.(png|jpe?g)\.webp$ {
try_files
$uri
/wp-content/plugins/webp-express/wod/webp-realizer.php?xdestination=x$request_filename&wp-content=wp-content
;
}
# ------------------- (WebP Express rules ends here)
location /error/ {
alias /home/admin/web/[мойдомен]/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/admin/web/[мойдомен]/stats/;
include /home/admin/web/[мойдомен]/stats/auth.conf*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/admin/conf/web/[мойдомен]/nginx.ssl.conf_*;
include /home/admin/web/[мойдомен]/public_html/*.conf*;
}
/en/content/images/image.jpg
попадает в location / {
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
fastcgi_hide_header "Set-Cookie";
}
location ~* .+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$
^~
.location ^~ /en/content/ {
rewrite ^/en/(.*) $scheme://mydomain/$1 permanent;
}
curl -I https://mydomain/en/content/images/image.jpg
HTTP/2 404
date: Tue, 06 Jun 2023 21:12:42 GMT
content-type: text/html; charset=utf-8
vary: Accept-Encoding
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Lk6wjMXZOhfRgrphHqrIQP%2BMHgnx6kWnLJW6m8ZdoHiHJ7VQWX4oDiuGFJRSnKourWpCrJWh8bmjE35FKgqlozueWCM%2FvldltX7blW93PAsOm9HT8LXb79%2BnkGlN1Q%3D%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 7d33a7afefe9bbfe-FRA
alt-svc: h3=":443"; ma=86400