CodeIgniter Forums
HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username (/showthread.php?tid=58784)



HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username - El Forum - 07-18-2013

[eluser]johanriyan[/eluser]
hello guys,

i want to create url like this :
www.example.com/username

how to handle controller, model and view.

thks guys


HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username - El Forum - 07-18-2013

[eluser]plain jane[/eluser]
You mean to say you want to remove index.php from the URL?


HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username - El Forum - 07-18-2013

[eluser]johanriyan[/eluser]
thks for respons.
but this problem has solved it.

i use routes like this :
Code:
$route['user/(:any)'] = "user/view";

$route['(:any)'] = "user/view";



HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username - El Forum - 07-19-2013

[eluser]sv3tli0[/eluser]
Code:
$route['(:any)'] = "user/view/$1";
Is correct way to catch the username..

How ever there is one big problem when you want to put such (:any) route..
You lose all normal routes ( /controller/method ) because all are going to user/view..
So you need to write in as routes all pages your site has before that :any..

It may be easier if you set a few type of pages with prefix forbidden for username ..
So "/settings" will load all settings page and etc..
This is the same way as Facebook routes work.


HOW TO CREATE URL AFTER DOMAIN AS USERNAME LIKE www.example.com/username - El Forum - 07-19-2013

[eluser]johanriyan[/eluser]
yes i want ulr as facebook.
thanks sv3tli0.