PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] Yii why this route does not match

 March 12, 2022     routes, yii     No comments   

Issue

I want to create simple routes for article routes but unsuccessfully. I have first route which should match regular expression and second like a slug route. Second one works well but the first one does not match nothing. What is wrong with this route?

    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
            'article/<action: (index|view|delete|create|update)>' => 'article/<action>',
            'article/<slug>' => 'article/view'
        ],
    ],

Solution

There should be no space after action::

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        'article/<action:(index|view|delete|create|update)>' => 'article/<action>',
        'article/<slug>' => 'article/view'
    ],
],


Answered By - rob006
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing