CodeIgniter Forums

Full Version: Add a parameter to the URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hello everybody,

It was difficult to write a title about my problem but i'm going to explain you here.

I would like to developp a website that will offer to create their own spaces with blog, forum, file management...

There would be the main website that I will call as example There would be at this URL the main platform with a portal, forum for everybody. To be on the common forum, I would like that the URL be

Blue = domain name
Green = sub-folder of "application"
Orange = controler
Yellow = parameter

All of that was for the common platform but how could I do assign in the URL the name of space created by an user like :

Purple = space of the user.

How to change in the URL the name of the spaces to redirect to the specified. It could be considered as a parameter but not a the end of the url.

How to do that with code igniter or with only php.

I hope that you will understand my question and that you will help me to find a solution.

El Forum

[eluser]Alias M2K[/eluser]
Man, you should go through the CodeIgniter URL's section in the CodeIgniter Documentation If you already had, and is still clueless, here is a small hint:

If is a CodeIgniter powered app, with the default controller set to your controller, then it would hit your controllers index function.

Now, if you call another function, say f1, then the url would change to (Ok, don't get messed up by the long URL's :roll: you can use the site_url function in the URL Helper).

The above example URL will work only if you are making function calls with no parameters. If you want to make function calls with one or more parameters, then your URL's should look like these:
For 1 parameter:
For 2 parameters: etc.

For your forum idea, I think the best way would be to implement a function(view_topic), which accepts parameters like forum_id, thread_id, user_id etc and then workout your magic!

All the best dude Smile

El Forum

I know that but I don't want

I want a way to do

Parameter1 would be the name of the user space. That wouldn't be a function parameter but a simple parameter.

El Forum

How about using subdomains so instead of

you have

See here for more info

El Forum

Check out the URI Routing documentation

Inside your routes.php file you would have to do something like this
$route['(:any)/forum/viewthread/(:num)] = "forum/viewthread/$1/$2";

Now your viewthread method will accept two parameters. The first one is the username and the second on is the thread id.

El Forum

[eluser]Alias M2K[/eluser]
Routing is a good idea :-)