在我的.htaccess中,如果网址末尾包含/ undefinded /,我想将(301)重定向到父文件夹。
问题是父文件夹一直在变化。换句话说:
如果网址包含
domain.com/any-page/undefined/
重定向到
domain.com/any-page/
所以
domain.com/apples/undefined/应重定向到domain.com/apples/
domain.com/bananas/undefined/应重定向到domain.com/bananas/
domain.com/peas/undefined/应重定向到domain.com/peas/
等。
任何人都可以发布htaccess规则来实现这一点吗?
答案 0 :(得分:0)
在/root/.htaccess中尝试:
The "type" key for the route definition "middle_man_book_example" in
"/Users/ewandelanoy/Documents/Math_Software/Symfony_stuff/sym-book/src/MiddleMan/BookBundle/Resources/config/routing.yml"
is unsupported. It is only available for imports in combination with
the "resource" key in
/Users/ewandelanoy/Documents/Math_Software/Symfony_stuff/sym-book/src/MiddleMan/BookBundle/Resources/config/routing.yml (
which is being imported from "/Users/ewandelanoy/Documents/Math_Software/Symfony_stuff/sym-book/app/config/routing.yml")
答案 1 :(得分:0)
您可以在站点根目录中使用此规则.htaccess:
RedirectMatch 301 ^/(.+)/undefined/?$ /$1