我有一个 redirect-map.map 文件,其中有一些要重定向的 url,如下所示,但重定向设置不起作用:
/jewelry/test/costumes(.*)a1 https://test.com/jewelry/test/costumes.html;
/jewelry/test/glasses(.*)a1 https://test.com/jewelry/test/glasses.html;
/jewelry/test/hats(.*)a1 https://test.com/jewelry/test/hats.html;
我的 test.conf 文件如下所示:
upstream fastcgi_backend {
server unix:/run/php/php7.0-fpm.sock;
}
map $uri_lowercase $new {
include /etc/nginx/redirect-map.map;
}
server {
listen 80;
server_name test.com;
set $MAGE_ROOT /var/www/html;
set $MAGE_MODE developer;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
proxy_cookie_path /var/www/test/ "/; secure";
proxy_cookie_path /login_redirect "/var/www/test; secure";
location = / {
if ($new) {
return 301 $new;
}
}
}
server {
listen 443 ssl http2;
server_name test.com;
set $MAGE_ROOT /var/www/html;
set $MAGE_MODE developer;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
location = / {
if ($new) {
return 301 $new;
}
}
}