htaccess重定向(多域多语言)子文件夹通配符 [英] htaccess redirect (multidomain multilanguage) subfolder wildcard
问题描述
我安装了带多域和多语言的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.
,并且对于.com域,原因相同。
and of cause the same procedure for the .com domain
www.example.com/fr/* to www.example.com/
www.example.com/de/* to www.example.com/
我在网上上下搜索,但没有尝试过。
任何帮助都会非常
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/(.*)$ http://www.example.de/ [L,R=301]
RewriteRule ^pt/(.*)$ http://www.example.de/ [L,R=301]
RewriteRule ^es/(.*)$ http://www.example.de/ [L,R=301]
这似乎有用
现在是第二个域,因为我需要区分在.com和.de
and now for the second domain as I need to differentiate between .com and .de
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^de/(.*)$ http://www.example.com/ [L,R=301]
RewriteRule ^fr/(.*)$ http://www.example.com/ [L,R=301]
现在可以中断 www.example.de/fr/whatever
并将其重定向到 www.example.com
。
this now breaks www.example.de/fr/whatever
and redirects it to www.example.com
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/(.*)$ http://www.example.de/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example.de
RewriteRule ^pt/(.*)$ http://www.example.de/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example.de
RewriteRule ^es/(.*)$ http://www.example.de/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^de/(.*)$ http://www.example.com/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^fr/(.*)$ http://www.example.com/ [L,R=301]
这似乎可行。
任何更好的解决方案都值得赞赏
any better solution is highly appreciated
这篇关于htaccess重定向(多域多语言)子文件夹通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!