Codeigniter routes

Asked

Viewed 274 times

1

Galley the default route of the site is "http://localhost/" or "http://localhost/index.php"

when I go to the login page for example, "http://localhost/login" and not "http://localhost/index.php/login" as the codeiginiter obliges...

You can change that?

.htacess

<IfModule mod_rewrite.c>

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

</IfModule>

config.php file

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

Routes file is default

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

Controler, name "Login"

class Welcome extends CI_Controller {

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

and the View is inside a folder "login" that has inside a "enter php."

1 answer

2


There is a configuration in the folder application/config in the archive config.php which shall be configured as follows:

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';

but, your server must be configured url rewriting module.

One remark, if you are using Xampp must be poorly configured, then use the built-in PHP server, configuring the system environment variables and typing php -S localhost:8989 has a server running on this port (which can vary from computer to computer) is a test server that comes with the PHP (Starting with PHP 5.4.0, CLI SAPI provides a built-in web server.) that works perfectly.

  • It is already configured in such a way and mudulo too. Any other possibility? Thank you until the moment!

  • Not if it is not working I need to see what is in your login file and how is your folders and also has if you followed the naming of names! You can put that in your question @Higorlamonier ???

  • I edited with some information that I think you might want to know!

  • Cade the controller Login @Higorlamonier ??? You are running APACHE?

  • Controller Login is the same as Welcome, standard, but duly changed... Sorry I put the wrong... Yes, however through XAMP

  • If you type : http://localhost/index.php/login works?

  • Yes, it works. But without "index.php" it will not,"Object not found,404 error"

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.