Reputation: 2678
What i am trying to do is to create a custom rule in Yii for URL management.
The general URL rules are set in main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>'=>'<controller>/index',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
the .htaccess file is also set like
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
so i have URLs in the form
local/cp/xyz/create
Now i have a custom controller for which the current URL is like
local/cp/xyz/create/abc
what i want is
local/cp/abc/create
Upvotes: 0
Views: 993
Reputation: 4150
Assuming 'local/cp' is your application url, 'xyz' is the controller and 'abc' is some kind of variable (I'll call it myVar
), you'd need a rule like so:
'<myVar:\w+>/<action:\w+>'=>'xyz/<action>',
or
'<myVar:\w+>/create'=>'xyz/create',
Upvotes: 1