Welcome Guest, Not a member yet? Register   Sign In
simple 404 not found
#1

Hi guys, i have used codeigniter before and i have never had this issue. Im sutck in a 404 not found and i dont know whats happening.
Im on localhost using xamp.4.48 (Win64) OpenSSL/1.1.1k PHP/7.4.20 Server at localhost Port 804


Not Found
The requested URL was not found on this server

controller


Code:
<?php

class Onekey extends MY_Controller {

  public function __construct(){
      parent::__construct();

    $this->load->model('Onekey_model');
    }

    public function index(){
      $this->render('onekey', 'Onekey_model');
    }

    public function teste(){
      $this->render('teste', 'Onekey_model');
}

HTML
Code:
    ````<form method="post" action="teste" class="login_form" accept-charset="utf-8">
        <button>Entrar</button></form>````


Htaccess
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>


ErrorDocument 404 /index.php
</IfModule>


config
Code:
$config['index_page'] = 'onekey';
$config['base_url'] = 'http://localhost/';
Reply
#2

(This post was last modified: 06-22-2021, 11:03 PM by berendbotje91.)

Probably because you have configured xamp to start from /project-folder/public/ folder, and you are running it from /project-folder/.

However, I suggest running it from commandline tool on development enviroments as suggested in the user guide: https://codeigniter.com/user_guide/insta...nning.html
Reply
#3

So i changed
<form method="post" action="teste" class="login_form" accept-charset="utf-8">
<button>Entrar</button></form>
to
<form method="post" action="index.php/onekey/do_login" class="login_form" accept-charset="utf-8">

and its working now, but its not like it shud be. Any tips on how to config it? I didnt do any configuration on xamp
Reply
#4

(06-23-2021, 01:11 AM)alexisgarci Wrote: So i changed
<form method="post" action="teste" class="login_form" accept-charset="utf-8">
        <button>Entrar</button></form>
to
<form method="post" action="index.php/onekey/do_login" class="login_form" accept-charset="utf-8">

and its working now, but its not like it shud be. Any tips on how to config it? I didnt do any configuration on xamp


Read the user guide about installation and running the app: https://codeigniter.com/user_guide/insta...nning.html



If you want to run from an Apache Server (like XAMP) you need to configure it so it will run from the public folder inside the project folder. For example if your project folder is called MyCodeIgniter and is on the root of the C drive, you should configure XAMP to run from

Code:
C:\MyCodeIgniter\public\


However, probably most of us use the command line tool for development instead of XAMP/LAMP/WAMP. We start a server with

Code:
php spark serve


Secondly, there is an helper in CI4 for using forms: https://codeigniter.com/user_guide/helpe...light=form


Something else that might make you more familiar with CI4 is following the tutorial here: https://codeigniter.com/user_guide/tutorial/index.html
Reply




Theme © iAndrew 2016 - Forum software by © MyBB