Yii url重写奇怪的行为(.htaccess + urlmanager)

I am hiding index.php and making the url friendly with the following code

.htaccess

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

And in main config,

'urlManager'=>array(
               'urlFormat'=>'path',
                'showScriptName'=>false,
                'rules'=>array(

                ),
         ),

It works as expected, but the problem is it always redirects to the login page "site/login" when a non-existent url is entered. So, if the url is wrong/doesn't exist instead of showing a 404, it redirects to login page. What am I doing wrong?

Check rights to access actionError for guests. You can also turn on LogLevel debug in apache to track rewrite rules. But this seems to be more security rules issue than rewrite

When using Path urlFormat You need to activate useStrictParsing to render the 404 pages for incorrect URL, modify your config like this

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName' => false,
    'useStrictParsing'=>true,
    'rules'=>array(

    ),
),

see http://www.yiiframework.com/doc/api/1.1/CUrlManager#useStrictParsing-detail for more details