简体   繁体   English

使用htaccess从网址中删除最后一个子目录

[英]Removing last subdirectory from url with htaccess

I am trying to remove the last directory /feed from all urls with htaccess. 我正在尝试从所有带有htaccess的URL中删除最后一个目录/ feed。

/feed is added after different subdirectories of the root at different depths and my goal is to keep the entire url regardless its subdirectories except the last /feed. / feed添加在根的不同子目录之后,深度不同,我的目标是保留整个url,而不管除最后一个/ feed之外的其他子目录。

I've tried different rewriterules and redirectmatches without success. 我尝试了不同的rewriterules和redirectmatches,但没有成功。

您可以在根.htaccess中使用此规则:

RedirectMatch 301 (?i)^/(.*?)/feed/?$ /$1

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

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