mod_rewrite 适用于带有 en、es 的 URL,但不适用于 zh-tw 和 zh-cn?
我的网站采用 4 种语言,并通过以下模式进行访问:
http://example/index.php?lang=en
http://example/index.php?lang=es
http://example/index.php?lang=zh-tw
http://example/index.php?lang=zh-cn
我在 .htaccess 文件中使用以下 mod_rewrite 规则:
RewriteEngine on
RewriteRule ^([a-z]{2}(-[A-Z]{2})?)/(.*) $3?lang=$1 [L,QSA]
因此输入 http://example/en/index.php 和 http://example/es/index.php 有效地将我重定向到 http://example/index.php?lang=en 和 http: //example/index.php?lang=es 分别。但这不适用于 http://example/index.php?lang=zh-tw 和 http://example/index.php?lang=zh-cn
它只是说:在此服务器上找不到请求的文档。
这与连字符(zh-tw 和 zh-cn)有关吗?
我该如何解决这个问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
[AZ]
替换为[az]
。Replace
[A-Z]
with[a-z]
.