user6773842
user6773842

Reputation:

How to set urlmanager rule on multilanguage website in yii2?

We have multilanguage(ua, ru, en) website. And site language automatically inserts in url before any calling to controller/action.

For example if language is 'ua' than request to site/index will be

ourwebsite.com/ua/controller/action 

not

ourwebsite.com/controller/action

i18n module is standart yii2 i18n module.

I want to set in urlManager, that if language is 'ua' then you can download file. But if language is 'ru' or 'en' and you go on

ourwebsite.com/ru/download
or
ourwebsite.com/en/download

then you can't download file.

I tried:

'<language:(ua)>/download' => 'site/download'

But it doesn't work.

if to set

'ua/download' => 'site/download'

it will work on

ourwebsite.com/ua/ua/download
ourwebsite.com/ru/ua/download
ourwebsite.com/en/ua/download

Upvotes: 1

Views: 656

Answers (2)

Flavio Misawa
Flavio Misawa

Reputation: 171

There is an extension for that-> Extension

Upvotes: 0

Kishan Sanghani
Kishan Sanghani

Reputation: 279

This type of links with the settings

enablePrettyUrl = true; 
showScriptName = false;

Upvotes: 0

Related Questions