routing question

#1
[eluser]dadamssg[/eluser]
Is it possible(with CodeIgniter) to set up a site similar to twitter in that you can find different profiles at http://example.com/aporofile. I have a database full of profile users and their information but would love to instead of this

http://www.mysite.com/myfolder/profile.php?id=Bob

routed to this

http://www.mysite.com/Bob

But im not seeing how thats possible if i have folders at my root like 'myfolder' in my example. Hope that made sense!

#2
[eluser]flaky[/eluser]
you can achieve that with routes

http://ellislab.com/codeigniter/user-gui...uting.html

#3
[eluser]WebsiteDuck[/eluser]
I would use http://www.mysite.com/user/Bob when setting up your routes to avoid ambiguity. You may have to disallow certain usernames if you don't, depending on how you have your site set up.

#4
[eluser]dadamssg[/eluser]
Yeah i think its going to be easier if i use '/user/' bkaxrf.

Flaky, i read the guide and don't see how i can use a username where i want it because where i want it is where classes usually go...thats why i asked.

#5
[eluser]flaky[/eluser]
you would achive that like this, it's very basic far from perfect or for use in production

Code:
//redirect to controller user
$route[":any"] = "user/profile";

#6
[eluser]WebsiteDuck[/eluser]
Code:
$route[':any'] = "usercontroller/viewprofile/$1";

This should do what you want, although I haven't tested it. You'll have to change the controller and function, obviously.

#7
[eluser]dadamssg[/eluser]
that makes sense...let me know if this makes sense

1. reserve some usernames for my folder names
2. have that route to like you both wrote
3. in my viewprofile page i would need some code that would check to see if that username exists and if not check to see if its a folder and send to that folder.

im just worried about my folders that i have at the root being mistaken as users

#8
[eluser]dadamssg[/eluser]
im learning on my hosted account which already has my website coded in the non-framework/procedural way so i have folders where i store all of my files in. So for example i store just about all of my files in a folder ive called 'main'

http://www.myexample.com/main/index.php

i don't want that to be redirected to a profile page.

#9
[eluser]dadamssg[/eluser]
or this either...

http://www.myexample.com/main/event.php?id=234

#10
[eluser]flaky[/eluser]
it is far better to use ‘/user/' as bkaxrf said


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.