首页 文章

在heroku上部署codeigniter在localhost上工作正常但在heroku上的路径问题

提问于
浏览
2

我正在使用codeigniter在heroku上部署一个简单的站点 . 它在localhost(xampp)上运行得很好,但在heroku上却没有 . 在heroku上它需要index.php并且说无法加载模型'Core'并且它也区分大小写 . 我该怎么办?

我跑的时候

http:// localhost / herokuroot /

我的页面加载但是当我运行时

https://bugdevroots.herokuapp.com/

它说

404 Page Not Found

The page you requested was not found.

但它适用于

https://bugdevroots.herokuapp.com/index.php/Welcome

我的默认控制器是 welcome

我把这个包含在我的 .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
<IfModule !mod_rewrite.c>
        ErrorDocument 404 index.php
</IfModule>

在我的config.php中

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

2 回答

  • 0

    我也有同样的问题,这就是我到目前为止解决的问题 .

    首先,在你的 routes.php 内你必须设置你的页面

    $route['default_controller'] = 'pages/view';
    $route['(:any)'] = 'pages/view/$1';
    

    假设您的 views 文件夹中有一个名为 pages 的文件夹,其中包含您网站中的网页 . 在 routes.php 中添加后,转到 config 文件夹内的 autoload.php 并设置以下代码:

    $autoload['helper'] = array('url');
    

    然后将以下代码设置到 config 文件夹内的 config.php

    $config['base_url'] = 'your_heroku_link';
    $config['index_page'] = 'views/pages/home.php';
    $config['uri_protocol'] = 'REQUEST_URI';
    $config['sess_save_path'] = sys_get_temp_dir();
    

    在我的 index_page' 中是一个文件路径,其中存储了我的所有页面, home.php 是加载后将进入的页面 .

    设置所有这些只是将它推到你的heroku上

    $ git push heroku master
    

    并打开您的应用程序以查看结果

    $ heroku open
    

    这可能不是正确的答案,因为我仍在修复我的应用程序中加载css文件 . 但如果您需要参考,可以在github上查看我的代码:https://github.com/OariKirian/fy-stories-inc

  • 0

    在我的情况下,我找到了一个解决方案,首先将它部署到我自己的服务器,我得到了相同的错误 . 经过一些测试我发现,因为它是一个Linux服务器,案例是敏感的!因此,在使用首字母的第一个字母重命名我的控制器和模型文件后,现在一切都好了 .

相关问题