Vinoth kumar
Vinoth kumar

Reputation: 475

Url route in codeigniter notworking

application/config/routes.php

       $route['aboutus'] = 'footerpage/index/$2';

Url route concept is not working in codeigniter. Here try i to change the url footerpage/index/1 into aboutus

Url is like

        http:local.com/footerpage/index/1

want to be like this

       http:local.com/aboutus

Upvotes: 1

Views: 79

Answers (4)

Vali S
Vali S

Reputation: 1461

You should try this:

$route['aboutus/(:any)'] = 'footerpage/index/$2';

The uri would show the parmaeter passed as a variable to the controller.

Upvotes: 0

Nassim
Nassim

Reputation: 2876

I guess you are looking for this ?

$route['footerpage/index/[0-9]+'] = "aboutus";

I assumed that the number after index will vary ... but you can change [0-9]+ to 1 if doesn't change value like this

$route['footerpage/index/1'] = "aboutus";

hope that helps

Upvotes: 1

parth
parth

Reputation: 1868

as per my understanding 1 is id from database and it will not change, so in your controller "footerpage" and "index" function u can give id as 1 directly...no need to define id in routes

in routes

$route['aboutus'] = 'footerpage/index';

Upvotes: 0

CodeGodie
CodeGodie

Reputation: 12142

just use .htaccess, like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^local.com[nc]
RewriteRule ^(.*)$ http://www.local.com/$1 [r=301,nc]
Redirect 301 /footerpage/index/1 /aboutus

Upvotes: 0

Related Questions