Please help I want to use first URI segment into my CodeIgniter website.
Like when I open these url they opens my profile: http://www.facebook.com/buddyforever or http://www.myspace.com/zarpio
How can I do this with CodeIgniter? I checked _remap
function but first coming controller how to hide controller?
You can do this using the URL routing of codeigniter...
If you want your URL to be
http://www.mydomain.com/zarpio
and you want it to refer toyour_controller
, then do the following./config/routes.php
You can access it in your controller like this...
However I do not suggest this way of configuring URLs. A better way would be...
This way, you're just renaming your controller name
your_controller
tousers
.If you want to access profile of a user, you can do it like this...
Consider the order of routing. Since you wrote
users/(.*)
in your route, it will matchusers/zarpio
as well asusers/profile/zarpio
, and route both of them toyour_controller/$1
, which in the case of profile will give you a404 page not found
error. That is why you need to writeusers/profile/(.*)
beforeusers/(.*)
in your routing configuration.More information in codeigniter URI class documentation