Neeraj
Neeraj

Reputation: 197

404 error in yii. url not working

My url

'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>',
                                         ),

My htaccess

RewriteEngine  On
RewriteBase  /
RewriteCond   %{REQUEST_FILENAME} !-f
RewriteCond   %{REQUEST_FILENAME} !-d
RewriteRule    ^(.*)\?*$ index.php/$1 [L,QSA]

Upvotes: 0

Views: 447

Answers (1)

Rohit Subedi
Rohit Subedi

Reputation: 550

This works for me. Please try this

'urlManager'=>array(
    'urlFormat'=>'path',
        'rules'=>array(
            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),
        'showScriptName'=>false,
    ),

In htaccess:

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

Upvotes: 1

Related Questions