1

I have two languages installed on my website I went to the Language Filter plugin, and configured it. "Remove URL Language Code" to "Yes".

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

But after the change only www.example.com/en/ changed to www.example.com/ as it is set to default language

and www.example.com/es/ is as it is www.example.com/es/ How can I change it for both the languages?

1
  • The building of the language segment of the URL is done in the Joomla system languagefilter plugin, in the buildRule() function. So you could create a plugin which extended the Joomla languagefilter plugin class but overrode buildRule(). Then you could use that plugin instead of the Joomla one. If you're keen to do that then let me know and I can write up some more details as an answer. Commented Jun 17, 2023 at 20:06

1 Answer 1

1

The default behaviour of the plugin appears to be to only remove the language identifier for the default language when you have "Remove URL Language Code" to "Yes".

You may be able to achieve what you want by altering the .htaccess file to have it remove the language identifier from the URL. If you are comfortable with changing the .htaccess file you can try placing this code this after the mod_rewrite on statement and any other redirect statements.

RewriteCond %{REQUEST_URI} ^/es/$
RewriteRule ^es/(.*)$ /$1 [R=301,L]

I don't have a multilanguage environment to confirm that the above is going to achieve your desired results in your environment so it is provided as is, as a starting point. However, I have tested that the code snippet won't break your .htaccess -- meaning you won't receive a HTML 500 error.

Your Answer

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

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