简体   繁体   English

Apache htaccess 301 重定向到子文件夹导致重定向过多

[英]Apache htaccess 301 Redirect to subfolder causes too many redirects

Goal目标

On an Apache httpd server, I would like to redirect requests made to /cms/de/foo to /cms/de/foo/bar permanently.在 Apache httpd 服务器上,我想将向/cms/de/foo发出的请求永久重定向到/cms/de/foo/bar

Failed attempt尝试失败

Trying the following redirect in the .htaccess.htaccess中尝试以下重定向

Redirect 301 /cms/de/foo /cms/de/foo/bar

results in too many redirects.导致重定向过多。

As far as I understand it, the redirect is applied over and over again until it results in said error.据我了解,重定向会一遍又一遍地应用,直到导致上述错误。 An exact match could solve it, I believe, but I am unsure on how to accomplish it.我相信,完全匹配可以解决它,但我不确定如何完成它。

Language part语言部分

de represents the language and can be any of de , en and fr . de表示语言,可以是deenfr中的任何一种。 Would it make sense to cover all languages within the same redirect or have explicit redirects for each language?在同一重定向中涵盖所有语言或对每种语言都有明确的重定向是否有意义? The foo respectivley foo/bar path is the same for all languages. foo相应的foo/bar路径对于所有语言都是相同的。

Thank you @CBRoe for pointing out RedirectMatch .感谢@CBroe 指出RedirectMatch This works:这有效:

RedirectMatch 301 ^/cms/de/foo$ /cms/de/foo/bar

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

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