Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilanguage: Implementing a 301 when Removing URL Language Code #5129

Closed
wants to merge 2 commits into from

Conversation

infograf768
Copy link
Member

See wrong PR here (because the true is not placed where it should) and discussion: #5092

Test instructions, set a multilanguage site with en-GB as default site

  1. Remove URL Language Code is set to YES in the language filter
  2. Language to display will be the default site language. Note it.
  3. Search Engine Friendly URLs is set to Yes in Global configuration

When hovering on the language switcher module to get to the default site language, copy the link
It will be of the type http://mysite.com/en/ (if en-GB is the default site language)

Open this online checker: http://redirectdetective.com/
Enter the link you just copied. See results.
=>303 redirect
Apply patch, and test again the same link in http://redirectdetective.com/
=> 301 redirect


Here is a live example of a site where the patch has been applied:
Go to:
http://info-graf.fr/multi/fr/blog-fran%C3%A7ais-%C3%A5-tester/2-article-fr-fr.html

Hover the English flag of the language switcher.
The link is http://info-graf.fr/multi/en/home-en-gb/8-category-en-gb/1-article-en-gb.html
Copy the link in http://redirectdetective.com/ and Trace url.
It will show that the redirect is a 301

@fontanil
Copy link

@test
Patch works well for me. Thanks!

@lunalars
Copy link
Contributor

@test
Success if "Remove URL Language Code" is set to "YES" (with and without SEF enabled in global config)

@infograf768
Copy link
Member Author

Looks like you are confusing SEF and SEF rewriting. :)
I guess you meant SEF rewriting on or off. Right?

@ManuxGR
Copy link

ManuxGR commented Nov 17, 2014

I have already test this, it's working for both cases "remove language code from url" set to "yes" or set to "no"

@lunalars
Copy link
Contributor

@infograf768
Oh, yes :-)
Just checked again, and test is still successful.

@ManuxGR
Copy link

ManuxGR commented Nov 17, 2014

I will post back as soon as i have the duplicated content fixed. Right now i have about 350 duplications.

301 is working properly since 2 days. Probably in about 2 weeks they are going to be fixed.

@infograf768
Copy link
Member Author

I have already test this, it's working for both cases "remove language code from url" set to "yes" or set to "no"

In the last case there is no redirect indeed

@ManuxGR
Copy link

ManuxGR commented Nov 17, 2014

You are right once again.
I forgot i had also add "true" to line 315 and 320.

@Hackwar
Copy link
Member

Hackwar commented Nov 17, 2014

why are you doing the whole $uri->base().$uri->toString(array()) stuff? $uri->toString() would be the same...

@infograf768
Copy link
Member Author

@Hackwar
This is not the issue here. Some code comes from 1.6. beta and I am sure it can be modernised/corrected.
Let's separate issues please.

@smanzi
Copy link

smanzi commented Nov 17, 2014

@infograf768 Tested:

Condition are:

  • browser en-US
  • default site language: it-IT
  • secondary site language: en-GB

1st interaction. Being already in the Italian site go to another page:
1

2nd interaction. Language Switcher to English:
2

3rd interaction. Language Switcher back to Italian:
3

4th interaction. Login with user associated to en-GB:
loggin-in

5th interaction. Language switcher to Italian:
logged-in-to-other

@infograf768
Copy link
Member Author

Good find!
This means we also have to send a 301 when the user logs in and has the default site language as own language, right?

@smanzi
Copy link

smanzi commented Nov 17, 2014

Well... it is more the 5th that concerns me from an architectural point of view (303 for a user logging in and being redirected is totally OK).
4th and 5th are a non-issue SEO-wise (spiders do not log-in, hopfully...), but IMHO and really without the minimal intention to offend, everything here speak "bad implementation", and I'm not talking about this PR: something is wrong ab initio, I think. Again, do not take this personally this is not my intention.

@infograf768
Copy link
Member Author

I did not get the 5th one here. Just the 303 when user logs in. When switchinh back to the default language I have a 301

@infograf768
Copy link
Member Author

Concerning the implementation:
The functionnality was not designed to be used without language code at the origin.
But people kept asking for it and we did our best...

@smanzi
Copy link

smanzi commented Nov 17, 2014

OOPS... that's strange... How can this be?
If you want I can try to replicate in the on-line version of my test site and give you admin rights...

@infograf768
Copy link
Member Author

I am using Tamper Data addon for Firefox to trace this.

@Hackwar
Copy link
Member

Hackwar commented Nov 17, 2014

@smanzi fully agree with you here. Having 7 $app->redirect()s in the parse rule with mostly the same code looks pretty bad. Likewise with half a dozen checks if self::$sefs[$sef]. Simply said, this code is so complex, that I have huge difficulties reading/understanding it. Equally with imploding the array at one point and concatenating strings at the other point.

@smanzi
Copy link

smanzi commented Nov 17, 2014

My screenshots are from the native Firefox inspector, Network view: try with that...

@smanzi
Copy link

smanzi commented Nov 17, 2014

@Hackwar pfuiiii.... you make me feel a bit less dull: I broke my head trying to get a grasp of it!

@infograf768
Copy link
Member Author

@Hackwar
Apart your mistake above in the code suggestion, you should very well remember which were the conditions Christophe and I had to deal with to force this minimal implementation of multilinguism in Joomla 1.6 and upper.

Evidently, the base is flawed!
This series will NOT provide a Joomla multilingual for big sites. It is a well known fact.

We were told to wait for the UCM, etc. to get a real multilingual Joomla!. I.e. was to be for version 3....
You very well know where ucm is now... Yeah, deep in it.

I have fought since I co-founded Joomla! for languages and multilanguage.
And I was very much alone until Christophe came with the code abilities, as we had nobody else volunteering... including yourself.
Then we happily had bembelimen who extended the associations.

Apart from these 3, no one has worked on it deeply. No one. We have simply corrected and improved on the base we had to be B/C and I had to always beg to get testers.

This PR is a little improvement for those who care for SEO.

@infograf768
Copy link
Member Author

@smanzi
I confirm 5. when switching to the default language I have a 301 (Firefox Inspector)

@smanzi
Copy link

smanzi commented Nov 17, 2014

@infograf768 OK, I will re-test, try to replicate on-line and then get in touch with you...

@Hackwar
Copy link
Member

Hackwar commented Nov 17, 2014

JM, I'm not saying that your work is not appreciated or that what you are trying to achieve is wrong. Quite the contrary. But I'm saying that when you are going to invest work into this, then please make it right and rewrite this plugin. I'm more than happy to help you out with this, but to be able to help you, I need to be able to understand what it is that you are trying to achieve with that plugin. The way the code is written, that is not possible right now, since it simply is too complex.

As you rightly said, UCM is dead. But I don't see why we couldn't get a proper multilang implementation in 3.x. And you know very well that I have to beg for every test and change as well.

@smanzi
Copy link

smanzi commented Nov 17, 2014

@infograf768 I confirm I have both 303 and 301 also with my on-line test site.

You can check at:

If you wish, just tell me and I'll send you credentials for admin/FTP/cPanel

@smanzi
Copy link

smanzi commented Nov 17, 2014

... there is also an Akeeba Backup .jpa file to download, if you prefer...

@smanzi
Copy link

smanzi commented Nov 18, 2014

@infograf768
Well, you know something? We are both right!
It seems to depend from the fact if you have already switched language in your state - either not-logged-in or logged-in.

If you want to consistently see my behavior, after (or even before!) point 5 click again on the flag of the same language you are already into: then you will start seeing 303 + 301

Something similar happens also on the home page even for not logged-in users:

Starting with a fresh (no cookie) browser:

  1. go to the home page: GET
  2. switch to other language: GET
  3. back to default language: 301 + GET
  4. again to other language: GET
  5. again back to default language: 303 + GET

@smanzi
Copy link

smanzi commented Nov 18, 2014

Some more info. Even for not logged in users:

  1. go to some (not home) page: GET
  2. switch to other language: GET
  3. back to default language: 301 + GET
  4. again to other language: GET
  5. again back to default language: 303 + 301 + GET

@smanzi
Copy link

smanzi commented Nov 18, 2014

May it be possible that everything derives from the need of having (explicitly for NON-SEF, implicitly for SEF) the lang=xx parameter on the URI, even for the default language?

If without SEF enabled I go to the home page I get this:

GET http://example.com/
303 -> http://example.com/index.php?lang=it

Now think of this: if we modify the rules of the game and we say: we levy the need of the lang parameter and if it is missing from the NON-SEF URL we just serve the default language?
At the same time we should also alter a little bit the code of the Language Module.

In Language Module:

add a "?switchlang=xx" parameter to every URI in the "flags" (both SEF or NOT SEF)

in languagefilter:

if (we have the switchlang param set)
{
    set the cookie for it
    remove it from the URI
}


if (the lang=xx parameter or /xx/ is present)
{
    honour it, serve the page and be happy
}
else // no lang
{
    if (this is the home page)
    {
        if (the cookie is set && cookie != default language)
        {
            redirect 303 to the correct language home page (with &lang=xx or /xx/, depending on SEF)
        }

        serve the default lang home page
    }
    else // no lang, not the home page
    {
        if (SEF && !remove_default_language_code)
        {
            T.B.D.: probably just a 404 or a 301 to the page with /xx/, maybe according to a new option
        }
        serve the default language page
    }
}

Everything seems to me to be B/C too...
Am I missing some point?

@smanzi
Copy link

smanzi commented Nov 18, 2014

the switchlang=xx parameter should also be added to the login logic...

@infograf768
Copy link
Member Author

@smanzi:
Ref: #5129 (comment)
I still do not get any 303, even on your site.

Please test my demo site above

and

If without SEF enabled I go to the home page I get this:
GET http://example.com/
303 -> http://example.com/index.php?lang=it

No, it is impossible and I do not confirm it at all. SEF off we always get a 200 directly.
(Except when it is a first visit and the param is to Browser settings, but this is to be expected)

@infograf768
Copy link
Member Author

@smanzi
my skype is infograf768

Let's share screen there and I will show you

@stellainformatica
Copy link
Contributor

@test
The patch works as expected, with the patch applied I see now a 301 redirect
screen shot 2014-11-18 at 11 10 32

@smanzi
Copy link

smanzi commented Nov 18, 2014

@infograf768
Jean-Marie, I'm getting 303 + 301 on your site too (for English page)... then It must be something else: browser?

My site is stock 3.3.6 with the following exceptions:

  • Installed Akeeba Backup
  • Installed com_patchtester
  • Installed a content plugin of mine that does markdown parsing

I'm going to open Skype later (about 1 hour...) Don't you have TeamViewer for screen sharing? I normally use that... never tried with Skype...

@smanzi
Copy link

smanzi commented Nov 18, 2014

capture

@smanzi
Copy link

smanzi commented Nov 18, 2014

On Jean-Marie site try switching between fr-FR and en-GB several times: at one point it start issuing 303 as well. Once started it does consistently. At least, this is what I'm seeing here: if nobody else has this problem it must be something local on my PC (Windows 8.1, Firefox 33.1)

@infograf768
Copy link
Member Author

I think we are going to merge this as we have already many positive tests and you are the only one to get a 303 for current navigation.
Getting two 3xx redirects before the 200 is anyway weird. I have never seen that on the web,
(BTW, all tests should be done on staging, not on 3.3.6)

I am on skype right now if you want to see here what goes on

@ManuxGR
Copy link

ManuxGR commented Nov 18, 2014

Sorry but i can not follow sometimes, it gets complicated for me. But if you need any help testing or an opinion let me know.
Anyway, my skype is manos-sx feel free to add me and ask for help.

@smanzi
Copy link

smanzi commented Nov 18, 2014

@infograf768
Hi Jean-Marie: sorry but I've been out for a while...

I think we are going to merge this as we have already many positive tests and you are the only one to get a 303 for current navigation.

As you wish, but as I told you in the other PR I have other concerns about having many links generating 301 on a site and namely:

  • Is this going to have a SEO impact?
  • Is this going to create problems to sitemap generators?
  • Will this litter my Webmaster Tools?

Getting two 3xx redirects before the 200 is anyway weird. I have never seen that on the web,

I trust you, but as you've probably seen on my last screenshot I'm getting those also on your site...

I will probably be on-line later if... I don't have to rush to the hospital: kidney stones are haunting me since a couple of days 😧

@Hackwar
Copy link
Member

Hackwar commented Nov 18, 2014

Providing a bunch of improvements to the languagefilter plugin: #5135

@lunalars
Copy link
Contributor

I think i found a way to reproduce the 303s ...
Tested on Ubuntu 14.04 with Firefox 33.0 (Firebug and Firefox Dev Tools) and Chromium 38 (Dev Tools).

First clear browser cache and then go to http://info-graf.fr/multi/

In Firefox switch to italian, french, italian, english (301), italian, french, italian, english -> 303 and you are still on italian.

In Chromium i had to go through this cycle one more time and on the last switch to english i get 301 + 303 and am still on italian.

Now deactivate caching in Firebug and Chromium Dev Tools (didn't find a way for Firefox Dev Tools) and try again: all should be fine (no more 303).

So maybe the question is: do crawlers use cache?

@infograf768
Copy link
Member Author

I guess that crawlers do not use your browser, therefore not the browser cache.

@infograf768
Copy link
Member Author

This patch is now included in Hannes PR #5135

@infograf768
Copy link
Member Author

#5135 includes this code. Closing.

infograf768 referenced this pull request Dec 2, 2014
Change language string names

Add extra large class to field

Don't check for empty new url if in advanced mode

Remove not null constraint in db

Remove not null constraint in db (2/2)

Add extra check for a 3xx code

Port to all databases

Add missing update files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants