Codeigniter-在此服务器上找不到请求的URL [英] Codeigniter - the requested URL was not found on this server

查看:62
本文介绍了Codeigniter-在此服务器上找不到请求的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里,我的沮丧情绪上升到了新的高度.我试图在codeigniter中创建一个简单的登录系统,但我无法使其正常工作.

For the last couple of days my frustration has grown to new heights. Im trying to do a simple login system in codeigniter and I cant get it to work properly.

提交登录表单时,出现以下错误:

when submitting the login form I get the following error:

在此服务器上找不到请求的URL/wishlist/login_controller/login.

The requested URL /wishlist/login_controller/login was not found on this server.

这是表格:

<form method="post" action="<?php echo base_url()?>login_controller/login">
<input type="text"placeholder="E-mail" id="email" name="email">
<input type="password" placeholder="Password" id="password" name="password">
<input class="btn btn-primary span2" type="submit" id="sign-in" value="Sign In">
</form>

这是我在login_controller中的登录功能:

Here is my login function in login_controller:

class Login extends CI_Controller {


function login() {

    $data['error'] = 0;

    if ($_POST) {

        $this->load->model('user_model');
        $email = $this->input->post('email', true);
        $password = $this->input->post('password', true);
        $user = $this->user_model->login($email, $password);

        if (!$user) {
            $data['error'] = 1;
        } else {
            $this->session->set_userdata('userID', $user['userID']);
            $this->session->set_userdata('firstname',    $user['firstname']);

            redirect(base_url().'admin_controller');

        }
    }

    $this->load->view('home_view');
}

我在本地主机上使用wampserver.这是它尝试访问的URL:本地主机/愿望清单/login_controller/登录

I'm using wampserver on localhost. Here is the url that it tries to access: localhost/wishlist/login_controller/login

我正确的假设是base_url()之后的第一部分是控制器,第二部分是该控制器中的函数吗?

Am I correct in assuming that the first part after base_url() is the controller and the second part is the function in that controller?

config文件夹中的几个设置.

A couple of settings from the config folder.

$config['base_url'] = '';
$config['index_page'] = 'index.php';
$route['default_controller'] = "site_controller";

推荐答案

请重命名您的控制器,

class Login extends CI_Controller {

class Login_Controller extends CI_Controller {

那你就可以做

<form method="post" action="<?php echo site_url('login_controller/login'); ?>">
<input type="text"placeholder="E-mail" id="email" name="email">
<input type="password" placeholder="Password" id="password" name="password">
<input class="btn btn-primary span2" type="submit" id="sign-in" value="Sign In">
</form>

然后使用此:

$config['base_url'] = 'http://localhost/wishlist/';
$config['index_page'] = '';

和htacees:

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

如果还不够,请在以下行切换config.php文件:

if it's not enought switch config.php file at line:

| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'            Default - auto detects
| 'PATH_INFO'       Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'     Uses the REQUEST_URI
| 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';

我使用AUTO也许您需要QUERY_STRING或REQUEST_URI选项

i use AUTO maybe you need QUERY_STRING or REQUEST_URI option

这篇关于Codeigniter-在此服务器上找不到请求的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆