1

I have a single Drupal 7 install running in 2 languages, on 2 domains, but currently using a language prefix as selection. Content can be access as follows:

English
mysite.com/content/wonderful
mysite.de/content/wonderful

German
mysite.com/de/content/wunderbar
mysite.de/de/content/wunderbar

I will change to domain language selection, so that one language is accessible on each domain:

English
mysite.com/content/wonderful

German
mysite.de/content/wunderbar

The setup works wonderfully on my dev server, but all the old links with the /de/ language prefix will be broken.

Is there a way to 301 them all with one fell stroke? Or how can I detect and strip the prefix in /de/content and at the same time redirect to .de/content? Is this best accomplished in .htaccess?

For German content, the appropriate redirect pattern would be as follows:

mysite.com/de/content/wunderbar -> mysite.de/content/wunderbar mysite.de/de/content/wunderbar -> mysite.de/content/wunderbar

Since English has no language prefix, how can I subsequently detect English content that is trying to be accessed on the .de domain and redirect accordingly?

1 Answer 1

2

I had the same issue and solved it by putting a 301 redirect in the htaccess file:

# 301 rewrite for all prefixed language nodes to their own domain
RewriteRule ^en/(.*)$ http://example.com/$1 [L,R=301]
RewriteRule ^de/(.*)$ http://example.de/$1 [L,R=301]

Then I generated a new sitemap and inserted it in the google webmaster tools. I'll monitor the performance impact of this solution. Update is coming in two weeks!

1
  • 1
    How was the outcome?
    – Volker
    Apr 25, 2017 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.