Yii应用程序在localhost上工作正常,但抛出"未找到" GoDaddy.com上的错误

时间:2015-01-02 01:08:52

标签: php apache .htaccess yii yii-url-manager

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

  

未找到

     

找不到请求的网址/网站/ Search_Best_Boat_Deals   这个服务器。

     

此外,尝试时遇到404 Not Found错误   使用ErrorDocument来处理请求。 Apache服务器在   website.com港口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=$1 [L,NC]

有什么不对?

2 个答案:

答案 0 :(得分:0)

改变规则的顺序。

在访问/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',
        ),
    ),

答案 1 :(得分:0)

专家!我感谢你的帮助。 .htaccess中的以下内容为我工作

 Options +FollowSymLinks
 IndexIgnore */*

 <IfModule mod_rewrite.c>
 RewriteEngine on

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

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