2

I have installed i18n module so two languages Japanese and English are available. I have set Japanese to the default language and also "language Language negotiation" to "path prefix only". So all the URL without language prefix show the Japanese pages and English pages with the prefix of "en".

What I want to do is to redirect some of URL with prefix to the same URL without prefix as I need to make some of the pages available only in Japanese. For example, when a user is trying to view my-site.com/en/cart the user is automatically redirected to my-site.com/cart as I want to make the my-site.com/en/cart unavailable.

I have tried path redirect but the redirect doesn't work though I set two cases as below

  1. "Language" to "All languages " ,"From" to "my-site.com/en/cart" and "To" to "my-site.com/cart".

  2. "Language" to "English" ,"From" to "my-site.com/en/cart" and "To" to "my-site.com/cart".

2 Answers 2

1

The below answer requires that at least part of your website is using Page Manager + Panels. In my opinion, they should anyway, but others will disagree. Both of these modules are tools, as opposed to solutions, so this answer will require that you research and understand these two modules. Link to excellent video tutorial. At the time of writing, this requires the -dev version of Ctools.

At the time of writing, this Ctools patch must be applied for the following instructions to work.

  1. Ensure that the page you want to redirect from, is managed by Page Manager. This page will have 2 variants.
  2. Add a "HTTP response" variant, with a 301 response to cart. More details on this step in another question. It's important that this variant is the topmost one. You can reorder them afterwards, if need be.
  3. On the HTTP variant, go to the "Context" tab on the left side, add a "Language" context, selecting "Current language".
  4. Go to the "Selection rule", and add a "User:Language" == "English".
  5. Add a second variant, this time a Panels variant.
  6. In the second variant, add all the content that you wish to be part of the Japanse page.
5
  • Thanks for your response. It looks a bit complicated but I think it's a good opportunity to learn Page manager module as it seems to be very powerful. OK now I set up a variant "HTTP response" but don't find where to configure "Language == English" in the list of "Selection rule" I can see "User:language" but not the langue currently viewed with the prefix. Would you please specify me a bit more?
    – chinita7
    Jan 9, 2012 at 17:05
  • I made a mistake. The language handling is not complete, and a patch is necessary for my instructions to make sense. Sorry about that. Added link to the answer. Also expanded the step by step instructions, hopefully they are a bit easier to follow now. :)
    – Letharion
    Jan 9, 2012 at 19:11
  • Thanks I see. I just realized that the patch is for D7 but I'm on D6. It seems that I even probably can redirect some users with only specific roles to another language using this function. I was thinking there is no way to achieve that. I really hope this will be back ported to D6. Or I wish I could do that if I was a coder :)
    – chinita7
    Jan 10, 2012 at 2:56
  • The patch actually applies cleanly against Ctools-6 aswell. I would give it a try. :)
    – Letharion
    Jan 10, 2012 at 6:25
  • I also just tried to apply the patch to D6 making three plugin files and allocating them in respective directories. Then I fellowed your instruction until 3. When I add context "Language" two text forms appears, one for "Identifier" and the other one for "Keyword" but nothing mentioning "Current language"...
    – chinita7
    Jan 11, 2012 at 3:11
0

In .htaccess, add directive

RewriteRule ^en/(.*)$ http://my-site.com/$1 [L,R=301]
RewriteRule ^cn$ http://my-site.com [L,R=301]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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