htaccess redirect (multidomain multilanguage) subf

2019-09-01 07:48发布

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

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

www.example.de can be de/en/fr but not
www.example.de pt/es/cn

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/

they point to languages that are not set for this domain

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 .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.






a tiny step further

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]

this seems to work

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]

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.

how can I limit the rules assigning them only to the appropriate domain conditions?

1条回答
Summer. ? 凉城
2楼-- · 2019-09-01 08:35

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]

this seems to work.

any better solution is highly appreciated

查看更多
登录 后发表回答