0

Currently my URL is domain.de/site/home, domain.de/site/about.

But i want that my URL ist domain.de/home, domain.de/about etc.

I already have a really simple Controller. In this Controller i`ve a function for each Site:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site extends CI_Controller {
public function index() {
    $this->home();
}

public function home() {
    $this->load->view("site_header");
    $this->load->view("site_nav");
    $this->load->view("content_home");
    $this->load->view("site_footer");
}

public function about() {
    $this->load->view("site_header");
    $this->load->view("site_nav");
    $this->load->view("content_about");
    $this->load->view("site_footer");
}
}
1
  • Controller Home and Controller About, each with public function index() to serve? Commented Mar 18, 2014 at 7:37

2 Answers 2

2

Open application/config/route.php and add following route path

$route['home'] = "site/home";
$route['about'] = "site/about";
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that`s working ! Unfournetly i cant give you a vote up because reputation ..
-1

You can define the association between a URL pattern and a controller/action in your config/routes.php file. Read the docs here and you will understand how it can be done.

By default, your routes will be {domain}/{controller_name}/{action_name} unless you override that in routes.php where you can assign to your controller/action a different URL pattern.

So probably in your case you would need something along the lines of:

$route['home'] = 'site/index';
$route['about'] = 'site/about';

Even better you might want to set your site controller as default controller:

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

Then all requests starting from the base url will get directed to actions in your site controller. That is {domain}/{action_name} will be directed to site/action_name automatically.

2 Comments

Thanks that`s working ! Unfournetly i cant give you a vote up because reputation ..
Can the person who down-voted this please explain why?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.