htaccess - 重定向循环
为什么这会导致重定向循环?
Options +FollowSymlinks
RewriteEngine on
RewriteBase /summary/1/document/
RewriteRule !^[a-z]{2}/ /summary/1/document/en/ [L,R]
RewriteRule ^([a-z]{2})/ ../index.php?lang=$1&type=document
我想要实现的是:
如果没有指定语言,则重定向到英语:
示例:
website.com/summary/1/document --> website.com/summary/1/document/en/
website.com/summary/1/document/fr/ [no redirect]
当指定语言时,使用 lang 和类型参数在内部重写为 ../index.php 。
Why is this causing a redirect loop?
Options +FollowSymlinks
RewriteEngine on
RewriteBase /summary/1/document/
RewriteRule !^[a-z]{2}/ /summary/1/document/en/ [L,R]
RewriteRule ^([a-z]{2})/ ../index.php?lang=$1&type=document
What I am trying to achieve is:
If there's no language specified, redirect to english:
Example:
website.com/summary/1/document --> website.com/summary/1/document/en/
website.com/summary/1/document/fr/ [no redirect]
And when a language is specified, rewrite internally to ../index.php with lang and type parameters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自标志
L
:Apache 文档< /sup>: flag_l :由于重写的请求被交回给 URL 解析引擎,因此在从第一个重写规则重定向后,
尝试以下操作:
From Flag
L
: Apache Docs: flag_l :Since, rewritten request is handed back to the URL parsing engine, after redirect from the first rewrite rule,
Try this: