1

I've followed this guide for creating SEO-conform Multilanguage urls, now I need to fit url rules for a few modules using slug urls.

Used rule is working fine for reading urls, i.e. writing the url like

www.mywebsite.com/en/pages/hello-world

(it loads the right page).

But using createUrl function it returns a valid url only if slug does not contains any dash, i.e. with slug "hello" createUrl returns

www.mywebsite.com/en/pages/hello

but with slug "hello-world" createUrl returns

www.mywebsite.com/pages/hello-world/language/en

This is the used rule:

'<language:(en|de)>/<controller:pages>/<slug:[\w\-]+>'=>'pages/view'

And I'm calling createUrl in this way:

createUrl('pages/' . $slug)

I can't figure out what's wrong...

coddoc
  • 65
  • 1
  • 8

1 Answers1

0

Try this: '<language:(en|de)>/<controller:pages>/<slug:[a-z0-9-]+>'=>'pages/view'

Marcos
  • 1,240
  • 10
  • 20
  • Try putting in your ´config/main.php´ like here: http://stackoverflow.com/questions/8650904/yii-framework-url-routing?rq=1 – Marcos Jun 17 '13 at 22:45
  • It's already in config/main.php, indeed it work for handling hardcoded urls, but not for createUrl('pages/hello-world') – coddoc Jun 18 '13 at 07:25
  • The `'//'=>'pages/view'` inside the main.php array will redirect any url how match the expression. So why you cant do that way? – Marcos Jun 18 '13 at 12:39
  • It works for routing urls, it doesn't for creating url with yii function createUrl, that's my problem. – coddoc Jun 18 '13 at 15:46
  • 1
    Check this link: http://www.yiiframework.com/wiki/404/hyphenation-of-routes-in-url-management/ see if can help – Marcos Jun 18 '13 at 20:25