Hello, there is a link

http://localhost/index.php?r=page/index&name=about 

I want the link to appear as

 http://localhost/about 

Posted in config

 'urlManager'=>array( 'showScriptName' => false, 'urlFormat'=>'path', 'rules'=>array( '<name:\d+>'=>'page/index', ), ) 

As a result, all the links in the menu have changed, but only opens the "wrong url", how to achieve the result, tell me something?

  • 2
    Enough already - do4a

4 answers 4

This is not a valid link, because you told the framework that you are waiting for a number ('=>' page / index ')

read about regExp

      create / rewrite .htaccess

       Options Includes FollowSymLinks #hide index.php RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php 

      in config \ main


       // uncomment the following to enable URLs in path-format 'urlManager' => array( 'urlFormat' => 'path', 'showScriptName'=>false, 'rules' => array( // стандартное правило для обработки '/' как 'site/index' '' => 'site/index', // это пример добавления который заработал //'secondcontroller/<action:.*>'=>'secondcontroller/<action>', 'user/<action:.*>'=>'user/<action>', //'<action:.*>'=>'site/<action>', //закомментил а то глючило с ним '<controller:\w+>/<id:\d+>' => '<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', ), ), 

        Transferred .htaccess to / web earned, did not want to root