Reputation: 114
I want pretty url. I access these records using url below. Last segment is index id to access data using it. http://www.example.com/order/thank_you/344
How can I convert it into http://www.example.com/order/thank_you
How to implement and also I want last segment in page to access the data using it.
Upvotes: 1
Views: 114
Reputation: 56
If you want the url not to contain the id portion you could keep it in a session var and retrieve it at the thank_you method.
Upvotes: 0
Reputation: 952
$route['order/thank_you/(:num)'] = 'thanks/thank_you/$1';
The left hand side is the URL accessed by the users. And the right hand side is where your request going to.
For example, the request example.com/order/thank_you/344
is going to the function thank_you()
of the Controller thanks
.
$1
is the argument. If have more than one, just /$1/$2/
.
public function friends_profile ($id = NULL) {
echo "This is the ID I want to thank to " .$id;
}
The function arguments can be passed directly by the route. $id
is the argument passed by the URI.
By the way, check out the Codeigniter URI Routing Guide to get more information.
Upvotes: 1