Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Russian (cyrillic) URL addresses [Solved]


Go to End


15 Posts   5016 Views

Avatar
darianno

Community Member, 14 Posts

10 March 2015 at 5:03am

Edited: 10/03/2015 5:06am

Hello!

I would like to know, if there is a way, to have a nice Russian URL addresses (cyrillic) in SilverStripe CMS?

For example, I would like to have such URL addresses:

https://my-domain.com/pоссии-гиперссылка

I see that WikiPedia for example, using such type of URL addresses: https://ru.wikipedia.org/wiki/Заглавная_страница, so I assume it is possible to have such type of URLs.

I've been added "set_allowed_locales" to "ru_RU" in _config.php, but URL's always become like this (look at the image below):

I've tried this module, which transform cyrillic letters to latin, but that solutions is not good for me. I need cyrillic letters inside URLs.

What can I do?

Thank you for your help!

Avatar
Nightjar

Community Member, 28 Posts

10 March 2015 at 5:35am

Edited: 10/03/2015 5:36am

привет darianno

The filtering is failing, so it is falling back on the default as per: https://github.com/silverstripe/silverstripe-cms/blob/3.1/code/model/SiteTree.php#L1507-L1509

Try setting the config for multi-byte urls:
https://github.com/silverstripe/silverstripe-framework/blob/3.1/model/URLSegmentFilter.php#L49

In something such as mysite/_config/urls.yaml:

URLSegmentFilter:
  default_allow_multibyte: true

Then of course flush before trying to set your URL again.

I'm not 100% sure this will work, but try that first ))

Avatar
darianno

Community Member, 14 Posts

10 March 2015 at 5:48am

Edited: 10/03/2015 5:50am

Thank you for your fast reply!

It worked. Now I can save cyrillic URL, but I'm still having a problem. When I opened saved page with cyrillic URL, I get 404 error. Don't know why, I triple checked my URL, I also save and flush everything.

Any idea why I'm getting 404 ?

спасибо! :)

Avatar
Nightjar

Community Member, 28 Posts

11 March 2015 at 3:23am

пожалуйста

I have just tried creating a page, and it has worked. Perhaps you are viewing the wrong stage?
When you save a page, it just makes a draft. You must save and publish before the page is viewable to the public.

?stage=Stage and ?stage=Live can be used to switch between the two while logged in as admin (when viewing the page).

If it still is not working, you can try ?debug=1 or ?debug_request=1 to see if you can get any extra info about why it is not showing. It is worth noting that will you will need to be in dev mode first though.
http://doc.silverstripe.org/en/developer_guides/debugging/url_variable_tools/
http://doc.silverstripe.org/en/developer_guides/debugging/environment_types/

Avatar
darianno

Community Member, 14 Posts

11 March 2015 at 7:12am

I think somethings wrong with URL decoding/encoding...

I'm getting this error:

"NetworkError: 404 Not Found - http://mydomain.com/ru/%D0%B7%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F-%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0"

When I run "debug_request=1" i get this:

Debug (line 250 of RequestHandler.php): Testing '$Action//$ID/$OtherID' with '' on ErrorPage_Controller

Debug (line 258 of RequestHandler.php): Rule '$Action//$ID/$OtherID' matched to action 'handleAction' on ErrorPage_Controller. Latest request params: array ( 'Action' => NULL, 'ID' => NULL, 'OtherID' => NULL, )

Debug (line 184 of RequestHandler.php): Action not set; using default action method name 'index'

I forgot to mention, I'm using Silverstripe LanguagePrefix module. Maybe there's a problem causing by this module ?

Avatar
martimiz

Forum Moderator, 1391 Posts

11 March 2015 at 8:31am

Hi Darianno,

Could you try to run the site with Translatable only, without using the laguageprefix module, to find out if languageprefix is the cause of the issue?

Also I assume the site does work for a latin locale like en_US?

Martine

Avatar
Nightjar

Community Member, 28 Posts

12 March 2015 at 2:56am

Edited: 12/03/2015 2:57am

Are you clicking a link to produce that error?
What happens if you visit directly yourdomain.site/ru/заглавная_страница ?

Also towards solving the 404, check that you have the default locale set in your config:
https://github.com/Martimiz/silverstripe-languageprefix/blob/master/code/LanguagePrefix.php#L59

Also ensure that the page is created under the correct locale in the SiteTree (ie, you're editing the ru_RU tree, not the default if ru is not the default, etc.), because if the page doesn't exist on that language then it will of course 404.

Avatar
darianno

Community Member, 14 Posts

12 March 2015 at 9:34am

Edited: 12/03/2015 10:02am

I figure out what causing problem. This module: https://github.com/Martimiz/silverstripe-languageprefix

@martimiz: is this your module ? I've added new issue on GitHub.

I've tested this on clean version of SilverStripe, so I'm sure this module causing the problem.

languageprefix.yml

---
Name: languageprefix-extensions
---
SiteTree:
  extensions:
    ['LanguagePrefix']
---
Name: languageprefix-config
---
prefixconfig:
  locale_prefix_map:
    'en_GB': en
    'ru_RU': ru
  enable_duplicate_urlsegments: true

routes.yml

---
Name: modelascontrollerroutes
After: cms/routes#modelascontrollerroutes
---
Director:
    rules:
        '': '->/en/'
        '$Prefix/$URLSegment//$Action/$ID/$OtherID': 'PrefixModelAsController'

_config.php

SiteTree::enable_nested_urls();
Director::addRules(100, array(
    '' => '->/silverstripetest/en/',
));

Go to Top