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

元气小坏坏 提交于 2020-02-08 04:55:35

问题


My Yii site works perfectly fine, when run on my laptop (localhost). But, when copied to GoDaddy.com and run from there, I'm getting following error message:

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

My main.php configuration file has the following configuration for URL management

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



            ),
        ),

My .htaccess file is as follows:

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]

What can be wrong?


回答1:


Guy! I appreciate all your help. The following in the .htaccess worked for me

 Options +FollowSymLinks
 IndexIgnore */*

 <IfModule mod_rewrite.c>
 RewriteEngine on

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

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



回答2:


change order of rules.

It seems when accessing /website/Search_Best_Boat_Deals it resolved to Search_Best_Boat_DealsController and actionIndex.

try this

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


来源:https://stackoverflow.com/questions/27736282/yii-application-works-fine-on-localhost-but-throws-not-found-error-on-godaddy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!