Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8468491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:57:00+00:00 2026-06-10T15:57:00+00:00

pay attention to that ANYTHING_ELSE So, I have my controllers and actions that I

  • 0

pay attention to that ANYTHING_ELSE
So, I have my controllers and actions that I want to behave as normal in response to examples like this:

// for UserContoller with actionList and actionEdit
user/list
user/edit/25

But for everything that doesn’t fall under specific controllers and actions i want them to fall under one default controller and action like: BlogController and actionView. That is where ANYTHING_ELSE comes.

// ANYTHING_ELSE can be:
this-is-a-test-page
this/is/another/page/with/lots/of/slashes
this-has-extension.html


'urlManager' => array(
  'urlFormat' => 'path',
  'showScriptName' => false,
  'rules' => array(
    '<controller:\w+>/<id:\d+>' => '<controller>/view',
    '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
    '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
    'ANYTHING_ELSE' => 'blog/view',
   ),
),
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:57:02+00:00Added an answer on June 10, 2026 at 3:57 pm

    I shall explain step by step how to get this working.

    Step 1 – Create an Yii web app

    Navigate to your Yii framework path in your console and create a new webapp. In my case I used this in my console:

    cd c:\zeus\yii-1.1.10.r3566\framework
    yiic webapp c:\zeus\www\yiiblog
    

    where c:\zeus\yii-1.1.10.r3566\framework is my path to Yii php framework and c:\zeus\www\yiiblog is the path to my Yii webapp test folder

    Stept 2 – fake my domain to dev.yiiblog.com

    Go to C:\Windows\System32\drivers\etc and edit your hosts file by adding this line:

    127.0.0.1 dev.yiiblog.com
    

    Step 3 – alter apache httpd.conf file

    <VirtualHost *:80>
        DocumentRoot "c:/zeus/www/yiiblog"
        ServerName dev.yiiblog.com
        ErrorLog "logs/dev.yiiblog.com-error.log"
        CustomLog "logs/dev.yiiblog.com-access.log" common
    </VirtualHost>
    

    and restart apache service. I used in my windows console:

    net stop apache
    net start apache
    

    where my Apache 2 service is named “apache” not “apache2.2” like the default one.

    Step 4 – create a database and configure a database connection into Yii

    I’ve created a database yiitest and a user yiitest. Then I opened my Yii configuration file located ad /protected/config/main.php and edited the connection to MySQL:

    'db'=>array(
      'connectionString' => 'mysql:host=localhost;dbname=yiitest',
      'emulatePrepare' => true,
      'username' => 'yiitest',
      'password' => 'password',
      'charset' => 'utf8',
    ),
    

    Step 5 – download dburlmanager Yii extension

    Go to Yii dburlmanager, download the Yii dburlmanager extension http://www.yiiframework.com/extension/dburlmanager/ and extract it to your /protected/extensions folder

    Step 6 – Create MySQL database tables and add dummy data

    CREATE TABLE IF NOT EXISTS `articles` (
      `seoURL` varchar(100) NOT NULL
    ) ENGINE=InnoDB;
    
    INSERT INTO `articles` (`seoURL`) VALUES
    ('first-post'),
    ('another-post'),
    ('post/value'),
    ('website/page1');
    
    CREATE TABLE IF NOT EXISTS `pages` (
      `seoURL` varchar(100) NOT NULL
    ) ENGINE=InnoDB;
    
    INSERT INTO `pages` (`seoURL`) VALUES
    ('page-first-post'),
    ('page-another-post'),
    ('page/post/value.html'),
    ('page-website/page1');
    

    Step 7 – Create your Yii custom Controllers

    Create under /protected/controllers folder two php files named ArticleController.php and PageController.php:

    ArticleController.php content:

    <?php
    /**
     * @filename ArticleController.php
     */
    
    class ArticleController extends CController {
      public function actionView() {
        $this->render('view', array(
          'article' => isset($_GET['article'])?$_GET['article']:'',
        ));
      }
    }
    

    PageController.php content:

    <?php
    /**
     * @filename PageController.php
     */
    class PageController extends CController {
      public function actionView() {
        $this->render('view', array(
          'page' => isset($_GET['page'])?$_GET['page']:'',
        ));
      }
    }
    

    Step 8 – create your custom Yii views

    Create your view files corresponding to those controllers above with the path /protected/views/article/view.php and /protected/views/page/view.php:

    Article view content:

    <h1>Article View Test</h1>
    <br />
    <?php
        if (isset ($article)) echo "article: $article";
    ?>
    

    Page view content:

    <h1>Page View Test</h1>
    <br />
    <?php
        if (isset ($page)) echo "page: $page";
    ?>
    

    Step 9 – add custom Yii url rules

    Open again your main.php Yii config file and set your urlManager to something similar to:

    'urlManager'=>array(
      'urlFormat'=>'path',
      'class'=>'ext.DbUrlManager.EDbUrlManager',
      'connectionID'=>'db',
      'rules'=>array(
        '<article:[\w\/.-]+>'=>array(
          'article/view',
          'type'=>'db',
          'fields'=>array(
            'article'=>array(
              'table'=>'articles',
              'field'=>'seoURL'
            ),
          ),
        ),
    
        '<page:[\w\/.-]+>'=>array(
          'page/view',
          'type'=>'db',
          'fields'=>array(
            'page'=>array(
              'table'=>'pages',
              'field'=>'seoURL'
            ),
          ),
        ),
    
        '<controller:\w+>/<id:\d+>' => '<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
      ),
      'showScriptName'=>false,
    ),
    

    Step 10 – create .htaccess file

    Create a .htaccess file under your web app root and etid its content to:

    Options +FollowSymLinks
    IndexIgnore */*
    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
    

    Step 11 – test your SEO Friendly URLs

    dev.yiiblog.com/first-post
    dev.yiiblog.com/page-first-post
    

    etc

    Have fun creating awesome blogs or other web apps with complete url managing power.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like this site Pay attention to your address bar.
I want to execute a piece of code So that users can pay attention
I have created a base controller that each of my controllers inherit. In this
t: test Pay attention that it's a tab after : ,and I used this
Hi guys thanks for pay attention to this. Well im trying to replace every
I'm definitely confused on this point. I have an iPad application that shows 'Live
As the title suggests, I want to actually brute-force (don't pay attention, useless information)
PAY ATTENTION! You can't include Github scripts directly from Github after this change .
I'm new to Solr. Using Solr 1.4.1 I have a schema.xml that have this
So I have a Stateful .NET webservice (C#) that I would like Flex to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.