由于URL映射中的变化,我在使用两个参数重定向URL时遇到了问题,以前该URL看起来像
https://www.example.com/product/<id: number>/<slug: string>;
但随着当前更改,新网址看起来像
https://www.example.com/product/<slug: string>;
所以我需要将以前的URL重定向到新的URL,因为这些URL在Google上已建立索引。
我在nginx conf文件中尝试了以下代码,但无法获得预期的结果。
location /product/(.*)/(.*) {
return 301 https://www.example.com/product/$2;
}
请帮助我解决此问题。我检查了很多答案,但所有答案都使用查询参数而不是url参数。