Mostafa Talebi
Mostafa Talebi

Reputation: 9173

URI routing in codeigniter

As the title suggests, my issue is with codeIgniter.

I have used a code in an .htaccess file to remove index.php which works all OK.

But I need to go further in changing the URI:

My main controller is page(), so when a user is in my homepage, the URL-bar shows:

www.example.com/page/

(because homepage is index page, it does not show the page name as usual the controller suffice),

but If I go to registration page, the URL-bar shows:

www.example.com/page/register

Up to here everything is OK, but I want the codeIgniter to show my domain without the page() when the user is in my homepage, I don't want foolish www.example.com/page/ to appear and I think when someone is visiting index page, the URL-bar better to be www.example.com

Upvotes: 0

Views: 144

Answers (3)

cartalot
cartalot

Reputation: 3148

for the link to register:

  www.example.com/register

in config/routes.php

 $route['register'] = 'page/register';    

Upvotes: 1

Kanishka Panamaldeniya
Kanishka Panamaldeniya

Reputation: 17566

You can define a custom route in config/routes.php - for example:

$route['default_controller'] = 'page';

Then, http://example.com

goes to http://example.com/page

then if you did not specify any data , it will route to default controller.

Upvotes: 3

JanBo
JanBo

Reputation: 2933

You have everything explained here in great detail.

http://ellislab.com/codeigniter/user-guide/tutorial/static_pages.html there is an example here on the bottom how to do uri routing with routes.php file in codeigniter.

Upvotes: 0

Related Questions