Welcome Guest, Not a member yet? Register   Sign In
How can I remove the controller name from url ??
#1


.txt   htaacess.txt (Size: 171 bytes / Downloads: 77)
.txt   config.txt (Size: 17.92 KB / Downloads: 92)
.txt   site.txt (Size: 712 bytes / Downloads: 72)
.txt   route.txt (Size: 111 bytes / Downloads: 77)


Hi

I want to access my page like--> http://localhost/basicsite/home

currently I am getting it as-->  http://localhost/basicsite/site/home

or/and

I want to access my page like-->   http://localhost/basicsite/about


currently I am getting it as-->   http://localhost/basicsite/site/about


"site" is the name of controller .

I want to remove that "site" (name of controller) from URL

how to achieve it please help me with this .

those attachments are there showing required files you may want to know .

attachments are
1- htaccess file   ("at / root folder")
2- config.php     ("application/config/config.php")
3- site.php         ("application/controller/site.php")
4- routes.php    ("application/config/routes.php")

Thanks
Reply
#2

(This post was last modified: 10-07-2015, 04:15 AM by freddy.)

how long did you know ci ?

so here is i give simple tutorial about your issue

Code:
/*router*/
$route['home'] = 'site/home';
$route['about'] = 'site/about';




//view
Code:
<h1>Here is website</h1>
<a href="<?php echo site_url('home') ?>">Home</a>
<br>
<a href="<?php echo site_url('about') ?>">about</a>


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

class Site extends CI_Controller {

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

public function home()
{
echo "home";

}

public function about()
{
echo "about";
}

}


Hope this make sense, i give attachment, my condition is without index.php.

Attached Files
.zip   site.zip (Size: 2.03 KB / Downloads: 48)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB