简体   繁体   English

Codeigniter 3.0.4,在我的服务器上找不到404页错误

[英]Codeigniter 3.0.4 with 404 Page Not Found Error on my server

I am new to the codeigniter. 我是codeigniter的新手。 After developing a web app on my localhost .So i uploaded my site on server and then i imported my database. 在我的localhost上开发了一个Web应用程序。所以我在服务器上上传了我的网站,然后我导入了我的数据库。 after that i have changed the settings of database in database.php file .. and also i changed the base url in config.php file. 之后我在database.php文件中更改了数据库的设置..而且我也更改了config.php文件中的基本URL。

I am getting a 404 Page Not Found. 我找到了404 Page Not Found。 The page you requested was not found . 找不到您请求的页面 I dont know what is going wrong ..i have searched a lot but nothing helps. 我不知道出了什么问题..我已经搜索了很多,但没有任何帮助。 and my .htaccess file is empty ..means there is not a single line in it. 我的.htaccess文件是空的..意思是里面没有一行。 and one more thing is that i purchase this from godaddy hosting may be helpfull. 还有一件事是我从godaddy托管购买这可能是有帮助的。

my routes.php 我的routes.php

$route['default_controller'] = '';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

my controller doctorscont.php 我的控制器医生cont.php

<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Doctorscont extends CI_Controller {

   public function index() { 
         here is my code.....  */
   }
}

and my config > config.php 和我的配置> config.php

$config['base_url'] = ''; 
$config['index_page'] = 'index.php';

[1]: [1]:

You have to define doctorscont's route in routes.php. 你必须在routes.php中定义doctorscont的路线。

Please add this line at the end of routes.php then visit 请在routes.php的末尾添加此行,然后访问

$route['doctorscont'] = 'Doctorscont';

If you still get 404 error, please try If it opens, you may want to remove index.php on URL. 如果您仍然收到404错误,请尝试如果它打开,您可能想要删除URL上的index.php。 For this task, visit CodeIgniter URLs Guide 有关此任务,请访问CodeIgniter URL指南

Edit: 编辑:

Create a .htaccess file under your root (same folder with system and application) with the content below: 使用以下内容在根目录下创建.htaccess文件(与系统和应用程序相同的文件夹):

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Than open config.php and edit this line: 比打开config.php并编辑这一行:

$config['index_page'] = 'index.php';

to this: 对此:

$config['index_page'] = '';

Now you can get what you want. 现在你可以得到你想要的东西。

In version 3+ the filenames must contain the first letter of each file as upper case. 在版本3+中,文件名必须包含每个文件的第一个字母作为大写。 It will work in lowercase in your localhost environment but not on server. 它将在localhost环境中以小写形式工作,但在服务器上不工作。

Rename the file to ' D octorscont.php' and you can use the class names as lowercase . 将文件重命名为' D octorscont.php' ,您可以将类名称用作小写

class Doctorscont extends CI_Controller

Edit : http://www.codeigniter.com/user_guide/general/controllers.html#let-s-try-it-hello-world 编辑http//www.codeigniter.com/user_guide/general/controllers.html#let-s-try-it-hello-world

It seems you have not made some changes at apache2 config level please do below changes. 看来你没有在apache2配置级别做一些更改请在下面进行更改。

1)sudo a2enmod rewrite 1)sudo a2enmod重写

2)gedit /etc/apache2/apache2.conf 2)gedit /etc/apache2/apache2.conf

3)add below to end of your conf file 3)在下面添加到conf文件的末尾

 <Directory /var/www/html/> AllowOverride All </Directory> 

4) Restart apache2 service by below command. 4)通过以下命令重启apache2服务。 service apache2 restart service apache2 restart

Best of luck. 祝你好运。

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

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