htaccess重定向(多域多语言)子文件夹通配符

编程入门 行业动态 更新时间:2024-10-27 18:31:35
本文介绍了htaccess重定向(多域多语言)子文件夹通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我安装了带多域和多语言的typo3安装,其中不是每种域都设置了每种语言。

I have a typo3 installation with multidomain and multilanguage, where not every language is setup to every domain.

语言是 de / fr / en / pt / es / cn /

Languages are de/fr/en/pt/es/cn/

www.example.de 可以为 de / en / fr ,但不能为 www.example.de pt / es / cn

现在我搞砸了。 google索引了错误网址的负载,例如

now I have messed up sth. and google has indexed loads of wrong urls e.g.

www.example.de/pt/ www.example.de/es/ www.example.de/cn/

他们的积分

我在htaccess中摆弄姿势,将带有通配符(?)的错误网址重定向301到.tld

I am fiddling around in the htaccess to redirect 301 the wrong urls with wildcards(?) to the .tld

我正在寻找解决方案重定向,例如。

I am looking for a solution redirect eg.

www.example.de/pt/* to www.example.de/ www.example.de/es/* to www.example.de/ www.example.de/cn/* to www.example.de/

其中*表示语言参数后的完整字符串/路径。

where the * should represent the complete sting/path following the language parameter.

,并且对于域,原因相同。

and of cause the same procedure for the domain

www.example/fr/* to www.example/ www.example/de/* to www.example/

我在网上上下搜索,但没有尝试过。 任何帮助都会非常

I searched the web up and down but nothing I tried works. any help would highly apreciated.

更进一步

RewriteCond %{HTTP_HOST} ^www.example.de RewriteRule ^cn/(.*)$ www.example.de/ [L,R=301] RewriteRule ^pt/(.*)$ www.example.de/ [L,R=301] RewriteRule ^es/(.*)$ www.example.de/ [L,R=301]

这似乎有用

现在是第二个域,因为我需要区分在和.de

and now for the second domain as I need to differentiate between and .de

RewriteCond %{HTTP_HOST} ^www.example RewriteRule ^de/(.*)$ www.example/ [L,R=301] RewriteRule ^fr/(.*)$ www.example/ [L,R=301]

现在可以中断 www.example.de/fr/whatever 并将其重定向到 www.example 。

this now breaks www.example.de/fr/whatever and redirects it to www.example as well.

所以它看起来像第一个条件匹配,最后一个规则适用于法语。

so it looks like the first condition is matching and the the last rule is applied for french.

我如何将规则限制为

推荐答案

好,看起来每个条件和相应规则都需要写在一行中重复的

ok looks like every condition and respective rule needs to be written in a single line an repeated

RewriteCond %{HTTP_HOST} ^www.example.de RewriteRule ^cn/(.*)$ www.example.de/ [L,R=301] RewriteCond %{HTTP_HOST} ^www.example.de RewriteRule ^pt/(.*)$ www.example.de/ [L,R=301] RewriteCond %{HTTP_HOST} ^www.example.de RewriteRule ^es/(.*)$ www.example.de/ [L,R=301] RewriteCond %{HTTP_HOST} ^www.example RewriteRule ^de/(.*)$ www.example/ [L,R=301] RewriteCond %{HTTP_HOST} ^www.example RewriteRule ^fr/(.*)$ www.example/ [L,R=301]

这似乎可行。

任何更好的解决方案都值得赞赏

any better solution is highly appreciated

更多推荐

htaccess重定向(多域多语言)子文件夹通配符

本文发布于:2023-11-01 20:45:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550370.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通配符   文件夹   多语言   重定向   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!