我在 nginx 上有 WordPress (example.com) 并创建了页面 A,该页面具有永久链接example.com/a。Wordpress 没有带有永久链接example.com/b的页面。
我想内部重写 uri /b以显示页面/a,即当用户键入example.com/b时,WP 应该返回页面,因为它是example.com/a的请求(无 301/302 重定向)。
我尝试了各种 nginx 配置:
# this returns 404
location /b {
rewrite ^ /a last;
}
# this returns 302 redirect to example.com/a
location /b {
include fastcgi_params;
fastcgi_pass unix:/dev/shm/.php-fpm/socket;
fastcgi_index index.php;
fastcgi_send_timeout 45;
fastcgi_read_timeout 15;
fastcgi_param PATH_INFO "/a";
fastcgi_param REQUEST_URI "/a";
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
# same as above
location /b {
fastcgi_param PATH_INFO "/a";
fastcgi_param REQUEST_URI "/a";
}
如何做到这一点?提前致谢。