2017-04-06 91 views
1

我在codeigniter中部署了一個簡單的heroku網站。它在localhost(xampp)上工作得很好,但不在heroku上。在heroku上它需要index.php,並且說無法加載模型'Core',並且它也是區分大小寫的。我該怎麼辦?在heroku上部署codeigniter在localhost上正常工作,但在heroku上路徑問題

當我運行

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'; 

回答

0

我也有同樣的問題,這是我如何解決它至今。

首先,你的裏面,你routes.php必須設置

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

假設你views文件夾內有一個名爲pages文件夾包含在你的網站上的網頁頁面。添加這些在後您的routes.php去你autoload.phpconfig文件夾內,並設置如下代碼:

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

然後將以下代碼到你的config.phpconfig文件夾

$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

相關問題