Yii 应用程序在本地主机上运行良好,但在 GoDaddy.com 上抛出 "not found" 错误

Yii Application works fine on localhost, but throws "not found" error on GoDaddy.com

我的 Yii 站点在我的笔记本电脑 (localhost) 上运行时运行良好。但是,当复制到 GoDaddy.com 并从那里运行时,我收到以下错误消息:

Not Found

The requested URL /website/Search_Best_Boat_Deals was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at website.com Port 80

我的 main.php 配置文件具有以下用于 URL 管理的配置

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

            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

            'Search_Best_Boat_Deals'=>'site/vessels',


            '<slug:[a-zA-Z0-9-%]+>/'=>'site/Detailview',

            'message/inboxview/<messageId:[0-9]+>/'=>'message/inboxview',
            'message/view/<messageId:[0-9]+>/'=>'message/view',

            'message/sentview/<messageId:[0-9]+>/'=>'message/sentview',

            'message/compose/<id:[0-9]+>/<VesselId:[0-9]+>'=>'message/compose',
            'Gallery/ajaxUpload/gallery_id/<gallery_id:[0-9]+>'=>'Gallery/ajaxUpload',

            'site/activate/key/<key:[0-9]+>/mail/<mail:[0-9]+>'=>'site/activate',



            ),
        ),

我的.htaccess文件如下:

RewriteEngine on

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    # otherwise forward it to index.php
    RewriteRule ^([a-zA-Z0-9\-]+)$ index.php?page= [L,NC]

有什么问题吗?

更改规则顺序。

似乎在访问 /website/Search_Best_Boat_Deals 时解析为 Search_Best_Boat_DealsControlleractionIndex

试试这个

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'caseSensitive'=>false, 
    'rules'=>array(
        'Search_Best_Boat_Deals'=>'site/vessels',
        '<controller:\w+>/<id:\d+>'=>'<controller>/view',
        '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
        '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        '<slug:[a-zA-Z0-9-%]+>/'=>'site/Detailview',
        'message/inboxview/<messageId:[0-9]+>/'=>'message/inboxview',
        'message/view/<messageId:[0-9]+>/'=>'message/view',
        'message/sentview/<messageId:[0-9]+>/'=>'message/sentview',
        'message/compose/<id:[0-9]+>/<VesselId:[0-9]+>'=>'message/compose',
        'Gallery/ajaxUpload/gallery_id/<gallery_id:[0-9]+>'=>'Gallery/ajaxUpload',
        'site/activate/key/<key:[0-9]+>/mail/<mail:[0-9]+>'=>'site/activate',
        ),
    ),

伙计!感谢您的帮助。 .htaccess 中的以下内容对我有用

 Options +FollowSymLinks
 IndexIgnore */*

 <IfModule mod_rewrite.c>
 RewriteEngine on

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteRule ^.*$ /index.php [L] 
 </IfModule>