问题
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