简体   繁体   English

在服务器中上传后,codeigniter无法正常工作

[英]codeigniter is not working after uploading in the server

My site http://www.bishal.prtia.com/prT_base/ throw an 404 error while loading in the server. 我的网站http://www.bishal.prtia.com/prT_base/在服务器中加载时抛出404错误。

It works perfectly in the localhost . 它在localhost可以完美运行。 I tried changing everything that mentioned in this forum like changing .htaccess to web.config and changing base url routing config etc but it still throws an error. 我尝试更改此论坛中提到的所有内容,例如将.htaccess更改为web.config并更改基本url路由配置等,但仍会引发错误。

You need to do few steps. 您需要执行几个步骤。

  • Update base_url in config.php 更新config.php base_url
  • Update RewriteBase in .htaccess 更新.htaccess RewriteBase
  • Set Permissions 设置权限
  • if still not workable, add error_reporting(E_ALL) in index.php and see what it says 如果仍然无法使用,请在index.php添加error_reporting(E_ALL)并查看其内容

Check the following things once again: 再次检查以下内容:

  1. Make sure your base_url is proper as per your website address, not localhost 确保您的base_url根据您的网站地址正确,而不是本地主机
  2. Check routes.php file for default controller and make sure it is correct. 检查route.php文件中的默认控制器,并确保它是正确的。
  3. Make sure .htaccess looks like 确保.htaccess看起来像

RewriteEngine on RewriteCond $1 !^(index\\.php|assets|images|js|css|upload|favicon.png) RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule ^(.*)$ ./index.php/$1 [L]

Then check following thigs: Config.php 然后检查以下提示:Config.php

  1. $config['base_url'] = ' http://www.bishal.prtia.com/prT_base/ '; $ config ['base_url'] =' http://www.bishal.prtia.com/prT_base/ ';
  2. $config['index_page'] = ''; $ config ['index_page'] ='';
  3. $config['uri_protocol'] = 'REQUEST_URI'; $ config ['uri_protocol'] ='REQUEST_URI';

Routes.php Routes.php

  1. $route['default_controller'] = 'your controller name (like welcome)'; $ route ['default_controller'] ='您的控制器名称(如Welcome)';
  2. $route['404_override'] = ''; $ route ['404_override'] ='';
  3. $route['translate_uri_dashes'] = FALSE; $ route ['translate_uri_dashes'] =否;

Make sure php file name of controller start with capital letter like Welcome and also inside that file as well when inherit from CI_Controller 确保控制器的php文件名以大写字母开头(如Welcome),并且在从CI_Controller继承时也位于该文件内

Function inside Welcome.php: Welcome.php内部的功能:

public function index()
{
  $this->load->view('your view file');
}

Thanks 谢谢

I also faced this error. 我也遇到了这个错误。 I changed my .htaccess file [WORKED FOR ME] :- 我更改了.htaccess文件[适用于我]:-

.htaccess for Live Server :- .htaccess用于Live Server:-

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]

.htaccess for Localhost :- .htaccess用于Localhost:-

RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM