【问题标题】:404 Not Found in yii framework404 Not Found in yii 框架
【发布时间】:2016-01-01 10:04:37
【问题描述】:

我是 yii 框架的新用户。我有一个项目,它的名字是crm 现在当我尝试运行它时,它给了我404 Not Found 的错误,下面显示The requested URL /crm/web/index.php was not found on this server.,现在当我转到我的根 index.php 它有下一行<?php header('Location: /crm/web/index.php'); ?>,当我刚刚进入web/index.php时,它有很多代码现在的问题是它无法访问/找到web目录中的index.php我也尝试创建另一个文件testing.php并更改<?php header('Location: /livecrm/web/index.php'); ?><?php header('Location: /livecrm/web/testing.php'); ?> 但它对我不起作用我已经设置了 Environment Variables,所以现在该怎么办。

在此致谢

【问题讨论】:

    标签: php yii


    【解决方案1】:

    您正在使用 Yii2 并且在您的项目中有多个应用程序.. 从您的资源管理器中我看到了

    您的项目名为 livecrm

    在你里面有这个应用程序目录

    • 前端
    • livecrm
    • liveCRMV2.2
    • 活工厂

    其他

    那么你命名的"I've got project and its name is crm" 不存在

    但是如果你想在你的项目中执行一个你应该使用的 webapp(例如用于 webapp 前端),你的应用程序目录结构就完成了

    livecrm/frontend/web/index.php
    

    或用于 livecrm

    livecrm/livecrm/web/index.php 
    

    【讨论】:

    • 然后工作?...有问题吗?错误 ?解释得更好.. 发生了什么
    • 它现在可以工作,现在我正在删除数据库错误...谢谢
    【解决方案2】:

    确保路径 crm/web/index.php 中有 index.php 文件

    把这一行放到你的根 index.php 文件中。

    而不是您的标题位置:

    <?php
    $host  = $_SERVER['HTTP_HOST'];
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra = '/web/index.php';
    header("Location: http://$host$uri/$extra");
    ?>
    

    并检查您的 .htaccess 文件。

    应该是:-

    Options -Multiviews
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /crm/
    
    # if a directory or a file exists, use it directly
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # otherwise forward it to index.php
    RewriteRule . web/index.php
    

    【讨论】:

    • 你使用的是哪个版本的 Yii?
    • 我有项目并想配置但我不能,这就是为什么我也无法检查版本,因为项目不工作......
    • 是否有任何文件可以检查版本而不是 echo Yii::getVersion(); 函数。
    • .htaccess 代码用于根 .htaccess 文件或网络的 .htaccess 文件。
    • 它现在给Internal Server Error
    猜你喜欢
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-04-24
    • 1970-01-01
    • 2016-05-23
    • 2019-04-16
    • 1970-01-01
    • 2018-10-26
    相关资源
    最近更新 更多