6

I'm having a slight issue with a multi language site. I am using FaLang to handle translations of 4 languages (English, Spanish, French and Italian) on a 3.3.6 Joomla installation with English set as the default site language.

I have enabled the "Remove URL Language Code" in the language filter. When viewing the site in English my url's look like this

www.example.com/company/contact.html

And the language switcher shows the other languages like so:

www.example.com/es/company/contact.html
www.example.com/fr/company/contact.html
www.example.com/it/company/contact.html

My issue is that if I change the language to either of the other 3, my English URL's looks like this in the language switcher:

www.example.com/en/company/contact.html

When clicking on the link one is redirected with a 303 from .../en/... to .../....

As far as I know that is the intent of Joomla, but I'd like to remove the /en/ from my English URL's, so that when showing my website in any of the languages my English URL's look like this:

www.example.com/company/contact.html

I am using FaLang's language switcher but also experience this "issue" with Joomla's own language switcher / translation system.

I don't use any SEF components and haven't found any which could solve this, I believe I have to change something in the core routing of Joomla but alas I don't know where or what.

.htaccess as per request

RewriteRule ^en/(.*)$ http://www.example.com/$1 [R=301,L]
20
  • man before anything else - I read: Joomla 3.3.6 - forget anything else you do and simply go and update Joomla. anything below 3.4.7 is hugely vulnerable. If you can't update, then at least install the latest Admin Tools Pro as temporary solution, which contains firewall protection against the recent J vulnerability.
    – FFrewin
    Commented Feb 16, 2016 at 13:49
  • @FFrewin I have Admin tools pro installed, and planning to upgrade to 3.4.8 in the near future, however, it still doesn't solve the issue.
    – Epodax
    Commented Feb 16, 2016 at 13:50
  • The comment was not intented to solve the issue - just to trigger your attention about the outdated and insecure joomla version you are running.
    – FFrewin
    Commented Feb 16, 2016 at 13:52
  • @FFrewin I realise now that I didn't formulate it properly, I ment that upgrading to 3.4.8 didn't / won't solve the issue. None the less, I appreciate the heads up.
    – Epodax
    Commented Feb 16, 2016 at 13:58
  • 1
    @fruppel I have a redir rule in my .htaccess that does this, further more, a .htaccess file does not modify the URL itself, it can redirect it and change the end result, but not the "incoming" url itself.
    – Epodax
    Commented Feb 19, 2016 at 8:30

3 Answers 3

3
+50

As far as I know what you want isn't possible. The /en/ is needed so Joomla knows that you want to change the language. Because with www.example.com/company/contact.html Joomla would look in your language cookie and redirect to the currently active language. So for changing languages, you need to explicitely tell Joomla that you want to switch to english. Once english is active, the links should be without /en/.

6
  • I figured as much, but I have a feeling that it should be possible to tell Joomla that if there is no /en/ (Or any of the other language tags in the url) present then it should set the language to English.
    – Epodax
    Commented Feb 18, 2016 at 7:12
  • 3
    @Epodax, hi Epodax, I didn't continue on our previous comments discussion although I had a further look at this. I also came with a similar conclusion like the one Bakual wrote above. Despite I would also like to have the urls in such cases without the language code, for now this seems not possible, or at least not something obvious or easy to achieve. I may guess you are considering it SEO wise, but at the end I think it won't really hurt. But that was a good catch. I haven't ever noticed that previously.
    – FFrewin
    Commented Feb 19, 2016 at 7:52
  • 1
    @FFrewin Sadly this was also the conclusion that I came to myself when trying to solve it, I haven't tried to make any changes to the JRoute yet as I've never tried to alter core files yet, but also because I'm reluctant to modify core files. Although I believe that it should be possible as per my logic the site knows that the default language is "English" and should set the language according if no language is defined in the URL. - I will keep trying to find a soloution.
    – Epodax
    Commented Feb 19, 2016 at 8:28
  • 1
    Don't look at the router. Look at the language filter plugin. This is where this is done. See github.com/joomla/joomla-cms/blob/staging/plugins/system/… You could create your own plugin to avoid hacking core files.
    – Bakual
    Commented Feb 19, 2016 at 12:37
  • Unfortunately, replacing the language filter plugin is not possible as the use of joomlas own languagefilter plugin is hard coded into the cms-code (in libraries/cms/application/site.php). So you really do need to hack the core to make this happen.
    – jonasfh
    Commented Feb 19, 2016 at 22:23
1

2020: It is possible. Just go to Language Filter plugin, configuration. "Remove URL Language Code" to "Yes".

1
  • 1
    Welcome to JSE and thank you for contributing, @Zibi. Please take our tour. Commented Apr 29, 2020 at 21:24
0

Right now what you request is not possible. I find this behavior very annoying and I will send a pull request to Joomla developers to change this.

Meanwhile, you can use the redirect functionality to redirect your pages. For example, let's say that you have a page httx://yoursite.com/en/products.html, but you want to use the url httx://yoursite.com/products.html, then you have to create a redirection url in the Redirect Extension from /products.html to /en/products.html. The bad thing is that you must do this for every url you want to remove the language suffix..

I think too, this should be automatically calculated by Joomla.

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