CodeIgniter Forums
A question about domain.tld/username configuration and possible controller collision - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: A question about domain.tld/username configuration and possible controller collision (/showthread.php?tid=24316)



A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]vokic[/eluser]
Hey, my question is not about how to setup that pattern but about avoiding username = controller collision.

For example if I use .htaccess to remove index.php from the url and if I want users to have their homepage like domain.tld/username (like on twitter for example) how can I prevent someone from registering like settings for example, or checkThis if I plan or do not know yet what controller names I will have in future? Maybe someone registers like goodies and I decide to offer some goodies too in the future and I would like to have that as a controller..

I know I can create a list and check against that list but who knows what reserved names I will need in the future when application gets bigger?

How would you go about this?

And I know I can use wildcard domains to produce something like username.domain.tld but on a shared hosting it is not an option...

Thanks in advance...


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]Ben Edmunds[/eluser]
You could use class exists and method exists but that wouldn't work unless the file is already included/loaded. The only other dynamic way I can think of is to check if the controller file exists.


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]vokic[/eluser]
Hey thanks for the fast response, but I think you've kinda missed my point.

It is not about current controllers or methods but about reserving names for future usage.

As more as I think about it I don't see a unique solution than to think in advance and make a list of possible future controllers.. Which is very hard sometimes.. Smile


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]Ben Edmunds[/eluser]
Oh, well the cheapest way to do it would be to start all your controllers with some sort of prefix and then just add the prefix with routes.


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]vokic[/eluser]
Right.. But then I would have to incorporate that prefix within urls.. But maybe we can reverse that idea and put something like this: domain.tld/~username which is not that scary.. Hmmmm.. or even domain.tld/_username..

It's not perfect but hey.. Thanks man...


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]Ben Edmunds[/eluser]
No you wouldn't have to put that prefix in the url, that's what the route is for.

You just wouldn't have any users named whateverprefix_username.


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]vokic[/eluser]
Okay can you give an example of that theory?

What I understood is this for instance...

controller named prefix_goodies
route $routes['goodies'] = 'prefix_goodies'; ?
and we have a user with username goodies

Url for user profile and goodies controller without prefix in url would be: domain.tld/goodies right?
Or I am missing something here from what you said?


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]Ben Edmunds[/eluser]
You are right. Looks like I didn't completely understand again. Sorry.


A question about domain.tld/username configuration and possible controller collision - El Forum - 11-05-2009

[eluser]vokic[/eluser]
No problem... And this is really not a big deal or something of ultimate importance anyway Smile

I was just curious to see if somebody has a full proof solution for this situation..

Easy way out is to ditch the cheap hosting and get a decent VPS or something with wildcard support for username.domain.tld Big Grin But hey, you can't blame a man who want's to see the crowd response before he starts anything serious.. Right? Smile

So far that idea you gave me with domain.tld/~username seems like a logical choice.. Or I wlll just sit down and write some possible future controllers out of the head Smile

Thanks again...