Q:

Removing last subdirectory from url with htaccess

I am trying to remove the last directory /feed from all urls with htaccess.
/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.
I've tried different rewriterules and redirectmatches without success.

A:

You can use this rule in root .htaccess:
RedirectMatch 301 (?i)^/(.*?)/feed/?$ /$1

