Problems with urlManager

Hi! I have a links like ->
I want it look like
My urlManager have a rule, but it’s don’t work:
‘pattern’ => ‘portal/news/<url:\w+>’,
‘route’ => ‘portal/news/{and there url param string}’,
Help me please!


 ‘pattern’ => ‘portal/news/<url:\w+>,
  ‘route’ => ‘portal/news’,

And next in your code:

class PortalController extends ... {
  * @param $url  some text from title
   public function actionNews($url){

And do not forget enable a prettyUrl
In www directory place .htaccess

RewriteEngine on

# jeśli katalog lub plik istnieją, użyj ich
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# w przecwinym przypadku przekaż do index.php
RewriteRule . index.php

And enable mod_rewrite for apache
restart apache

1 Like

Thank you! It’s helped me)