Php 在heroku上部署codeigniter在本地主机上运行良好,但在heroku上存在路径问题
我正在heroku上部署一个简单的站点,这是我在codeigniter中创建的。它在localhost(xampp)上工作得非常好,但在heroku上却不行。在heroku上,它需要index.php,并表示无法加载模型“Core”,而且它也区分大小写。我该怎么办 当我跑的时候 我的页面会加载,但当我运行时 上面说Php 在heroku上部署codeigniter在本地主机上运行良好,但在heroku上存在路径问题,php,.htaccess,codeigniter,heroku,Php,.htaccess,Codeigniter,Heroku,我正在heroku上部署一个简单的站点,这是我在codeigniter中创建的。它在localhost(xampp)上工作得非常好,但在heroku上却不行。在heroku上,它需要index.php,并表示无法加载模型“Core”,而且它也区分大小写。我该怎么办 当我跑的时候 我的页面会加载,但当我运行时 上面说 404 Page Not Found The page you requested was not found. 但它对我们有用 我的默认控制器是welcome 我已将其包
404 Page Not Found
The page you requested was not found.
但它对我们有用
我的默认控制器是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>
我也有同样的问题,到目前为止我就是这样解决的 首先,在
routes.php中,您必须设置页面
$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';
假设在视图
文件夹中有一个名为页面
的文件夹,其中包含站点中的页面。在routes.php
中添加这些内容后,转到config
文件夹中的autoload.php
,设置以下代码:
$autoload['helper'] = array('url');
然后将以下代码设置到config.php
文件夹中的config
中
$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\u页面中,'
是一个文件路径,我的所有页面都存储在该路径中,home.php
是它加载后将转到的页面
设置好所有这些后,只需将其推到heroku上即可
$ git push heroku master
并打开应用程序查看结果
$ heroku open
这可能不是正确的答案,因为我仍在修复在我的应用程序中加载css文件的问题。但是如果您需要参考资料,可以在github上查看我的代码:在我的例子中,我找到了一个解决方案,首先将它部署到我自己的服务器上,在那里我遇到了相同的错误。
经过一些测试,我发现,由于它是linux服务器,所以区分大小写!
所以在用大写字母重命名我的控制器和模型文件后,一切都正常了
$ heroku open