【问题标题】:Yii Application works fine on localhost, but throws "not found" error on GoDaddy.comYii 应用程序在 localhost 上运行良好,但在 GoDaddy.com 上抛出“未找到”错误
【发布时间】: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


【解决方案1】:

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

 Options +FollowSymLinks
 IndexIgnore */*

 <IfModule mod_rewrite.c>
 RewriteEngine on

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

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

【讨论】:

    【解决方案2】:

    改变规则的顺序。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-29
      • 2020-08-21
      • 1970-01-01
      • 2015-01-03
      • 2017-04-16
      • 1970-01-01
      相关资源
      最近更新 更多