Welcome Guest, Not a member yet? Register   Sign In
Routes
#1

[eluser]kolxoznik1[/eluser]
I want to show user profiles like

www.mysite.com/username

I tried to do this with

Code:
$route['(:any)'] = "images/users_pictures/$1";

after this line I can call users pages like url above but get problem with long url ... not shorted yet with routers. For example I have
Code:
users/logout
So when I can controller users -> function logout it send me to users page (* logout function must redirect to main if everything is ok*)

When I delete my new route line everything work ok, so my functions works ! I need help with route.



Sorry for my poor English, suppose you understand my problem and can help me
Thank you
#2

[eluser]vbsaltydog[/eluser]
routes are matched in order from top to bottom so make your longer route paths first and your shorter route paths next:

Code:
$route['(:any)/(:any)/(:any)/(:any)'] = "wherever";
$route['(:any)/(:any)/(:any)'] = "wherever";
$route['(:any)/(:any)'] = "wherever";
$route['(:any)'] = "images/users_pictures/$1";
#3

[eluser]Dhanapal MCA[/eluser]
$route['(:any)/(:any)/(:any)/(:any)'] = "wherever";
$route['(:any)/(:any)/(:any)'] = "wherever";
$route['(:any)/(:any)'] = "wherever";
$route['(:any)'] = "images/users_pictures/$1";
#4

[eluser]InsiteFX[/eluser]
Why do you always have to repeat someone's else answer?

That's a good way to get banned form the forums...
#5

[eluser]PhilTem[/eluser]
[quote author="InsiteFX" date="1327046962"]Why do you always have to repeat someone's else answer?

That's a good way to get banned form the forums...
[/quote]

Maybe it's another type of spam-bot? Who knows how intelligent they are and what abilities they have nowadays Wink
#6

[eluser]kolxoznik1[/eluser]
Thank you for answer but I get an error trying to do as you write above.

Here is all my route
Code:
$route['default_controller'] = "main_page";
$route['404_override'] = '';

$route['upload'] = "images/upload_image";

$route['(:any)/(:any)'] = "auth/logout";

$route['(:any)/(:any)'] = "auth/login_from_index";

$route['(:any)'] = "images/users_pictures/$1";

The problem is that
Code:
$route['(:any)/(:any)']
do not work both only that one what is below in this example work only
Code:
$route['(:any)/(:any)'] = "auth/login_from_index";
but
Code:
$route['(:any)/(:any)'] = "auth/logout";
- do not work . Why?
#7

[eluser]Aken[/eluser]
To elaborate, routes work in order from most specific to most generic, so most specific pages need to be at the top.

If you create a (:any) route, it will work for ANY URL. Routes do not check if a controller or page exists in your application - it only knows what you tell it. So if you want a catchall route such as (:any), you also need to include routes for your individual static pages that exist.

Code:
$route['default_controller'] = "main_page";
$route['404_override'] = '';

$route['users/(:any)'] = "users/$1";
$route['users'] = 'users';

$route['upload'] = "images/upload_image";

$route['(:any)'] = "images/users_pictures/$1";
#8

[eluser]CroNiX[/eluser]
[quote author="InsiteFX" date="1327046962"]Why do you always have to repeat someone's else answer?

That's a good way to get banned form the forums...
[/quote]trying to get post counts up so they can post [spam] links




Theme © iAndrew 2016 - Forum software by © MyBB