在我的wordpress网站上,我想使用正则表达式重定向一些404

时间:2018-12-26 19:17:55

标签: wordpress redirect

因此,我的网站设置有一个/ plans /页面,该页面具有指向各个/ product /页面的链接。因此,用户可以访问/ plans /,然后单击/ product / plan-a /。但是,/ product /不是页面,访问它会导致404。此外,访问/ products / product-that-does-not-exist不存在也会导致404。

我的目标是拦截404并将这些用户发送到/ plans /页面,但仅当它是404时。如果URL用于有效产品,我希望它加载请求的页面。 / p>

因此,/ product / real-prodcut /会加载“真实产品”页面,而/ product / fake-product会加载/ plans /页面。

1 个答案:

答案 0 :(得分:0)

引用此已发布的问题和答案:Htaccess 301 Redirect a sub folder with exception

您应该能够这样写: RedirectMatch 301 ^ / products /((?! real-product-1 | real-product-2.php)。+)/ plans /