【发布时间】:2015-01-02 01:08:52
【问题描述】:
当在我的笔记本电脑(本地主机)上运行时,我的 Yii 网站运行良好。但是,当复制到 GoDaddy.com 并从那里运行时,我收到以下错误消息:
找不到
未找到请求的 URL /website/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]
有什么问题?
【问题讨论】:
-
/website.com不应出现在 404 错误中,除非您的 Web 根目录中有一个名为website.com的子文件夹,这是您的结构吗? -
是的,没错。但它应该有所作为吗?而且我实际上不喜欢 linux 托管对大小写有很大影响。但是我现在该如何解决呢?
-
这与 yii 无关,您将网站上传到错误的文件夹 - 这显然是 apache 错误。这意味着请求甚至没有到达 index.php
-
您需要弄清楚将 index.php 放在 GoDaddy 的哪个位置。我不知道他们的网络根是什么。 (www 或 public_html?)用户定义?还要检查它是否在没有
.htaccess的情况下工作,RewriteBase /在某些主机上可能无法工作。
标签: php apache .htaccess yii yii-url-manager