简体   繁体   English

htaccess将具有特定单词的文件夹重定向到其自己的父文件夹

[英]htaccess redirect folders with specific word to their own parent folder

New site is live and the old site made use of a bunch of useless "feeds". 新站点已启用,旧站点使用了一堆无用的“提要”。

Looking for an .httaccess 301 redirect command to redirect anything with "feed" in it to its parent folder. 寻找.httaccess 301重定向命令以将其中带有“提要”的任何内容重定向到其父文件夹。 There are thousands of them, so looking for a way to do it in one fell swoop. 有成千上万的人,所以寻找一种可以一口气做到这一点的方法。

Here are examples of the "folders" (which are really WordPress pages): 以下是“文件夹”的示例(实际上是WordPress页面):

http://example.com/listing/listing-name/feed/ http://example.com/listing/listing-name/feed/

http://example.com/listing/listing-name2/feed/ http://example.com/listing/listing-name2/feed/

Where "listing" always remains the same, but "listing-name" and "listing-name2" represents items that vary. “列表”始终保持不变,但“列表名称”和“列表名称2”表示变化的项目。

I would like them to be redirected to their parent "folder", like this: 我希望将它们重定向到其父级“文件夹”,如下所示:

http://example.com/listing/listing-name/ http://example.com/listing/listing-name/

http://example.com/listing/listing-name2/ http://example.com/listing/listing-name2/

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thank you! 谢谢!

You can use this redirect rule as your top rule: 您可以将此重定向规则用作首要规则:

RewriteEngine On

RewriteRule ^(.+/)feed/?$ /$1 [L,NC,NE,R=301]

# more rules below this

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM