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

Wednesday, January 12, 2022

[FIXED] Remove controller and action from url yii

 January 12, 2022     yii, yii-url-manager     No comments   

Issue

I want to hide controller and action name from url and only slug will show.E.g http://localhost/test-project/frontend/web/test-condition and "test-condition" is slug.I want to manage this from urlManager in my config/main.php


Solution

'urlManager' => [
            'class' => 'yii\web\UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,
            'rules' => array(
                ....
                '<slug:[a-zA-Z0-9_ -]+>-consult' => 'CONTROLLER NAME/ACTION',
            ),
        ],


Answered By - Subhasis Bhowmik
  • 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