ubuntu中的codeigniter始终显示“404 not found”

时间:2015-04-01 06:47:38

标签: codeigniter

欢迎页面仅显示。如果我创建新的控制器和视图意味着它显示'404 Not found'。

  

Controller - Create.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Create extends CI_Controller {
    public function index()
    {
       $this->load->view('create');
    }
}
  

查看 - create.php

<?php
 defined('BASEPATH') OR exit('No direct script access allowed');?> 
 <!DOCTYPE html>
 <html lang="en">
 <body>
       <h1>Welcome to CodeIgniter!</h1>
 </body>
 </html>

我在浏览器中运行过这样的程序 - “http://example.com/Create/”。但它显示404 Not Found。我也允许所有文件。

4 个答案:

答案 0 :(得分:1)

首先显示欢迎页面,因为在application \ config \ routes.php文件中欢迎使用默认控制器

$route['default_controller'] = "welcome";

只有默认控制器才能在没有index.php的情况下使用。

请尝试使用其他控制器"http://example.com/index.php/controllerName/functionName"

您可以参考:https://ellislab.com/codeigniter/user-guide/general/urls.html

答案 1 :(得分:0)

你有这些设置吗?

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

答案 2 :(得分:0)

我认为这是一个大写的问题。 Linux区分大小写。

修复是您确保将所有 <script type="text/javascript"> var type = $('#Type'); var category = $('#Category'); var country = $('#Country'); var product = $('#Product'); var table = $('#table'); $('#search').click(function () { var url = '@Url.Action("FetchProductProperties")'; table.empty(); $.getJSON(url, { type: type.val(), category: category.val(), country: country.val(), product: product.val() }, function (data) { $.each(data, function (index, item) { var clone = $('#template').clone(); clone.html($(clone).html().replace(/\[#\]/g, '[' + index + ']')); var cells = clone.find('td'); cells.eq(0).children('span').text(item.ID); cells.eq(0).children('input').val(item.ID); cells.eq(1).children('input').first().prop('checked', item.CheckOrNot) cells.eq(2).children('span').text(item.Name); cells.eq(2).children('input').val(item.Name); cells.eq(3).children('span').text(item.PropertyValue); cells.eq(3).children('input').val(item.PropertyValue); $('#table').append(clone.find('tr')); }); }); }); </script> 个文件名大写,即在控制器文件夹中,而不是controller将其更改为welcome.php

我希望这会有所帮助。

答案 3 :(得分:-1)

您需要启用mod_rewrite并设置&#34; AllowOverride&#34;选项&#34;所有&#34;在你的apache2.conf文件中。

要启用mod_rewrite,只需输入终端并输入以下命令:

a2enmod rewrite (as root user)

要在apache2.conf文件中设置AllowOverride All,您需要打开它,并在该部分中将AllowOverride选项从None设置为All,如下所示:

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

如果它不存在,那就写下来。

相关问题