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

[eluser]Gewa[/eluser]
How to make such routing that


www.site.com/sites/userX/controller/function/var1/var2

will behave like it was

www.site.com/controller/function/var1/var2


???
#2

[eluser]WanWizard[/eluser]
Something like
Code:
$route['sites/user(:any)/(.*)'] = '$2';
#3

[eluser]Gewa[/eluser]
userX can be ANY username , but the routing you gave didn't worked
#4

[eluser]mddd[/eluser]
The route doesn't work because 'any' can match more than a single uri segment.
If you write the route differently it will probably work:
Code:
$route['sites/([^/]+)/(.*)'] = '$2';
([^/]+) will match only one segment, leaving the second bracketed part to be 'controller/function/var/var/...'
#5

[eluser]Gewa[/eluser]
mddd, it's working like charm! thanks!
#6

[eluser]WanWizard[/eluser]
@mddd:

I don't use routes myself, and the manual explicitly talks about segment (singular) when referring to (:any) and (:num).

Learning all the time. Smile
#7

[eluser]mddd[/eluser]
I agree. The manual is unclear. I have suggest before that there should be another 'wildcard' for a SINGLE segment. It seems that most developers don't know that :any matches more than one segment. Of course, to be backwards compatible, :any should stay the way it is, maybe Confusedeg or something..
#8

[eluser]Clooner[/eluser]
[quote author="mddd" date="1279713749"]I agree. The manual is unclear. I have suggest before that there should be another 'wildcard' for a SINGLE segment. It seems that most developers don't know that :any matches more than one segment. Of course, to be backwards compatible, :any should stay the way it is, maybe Confusedeg or something..[/quote] That would be a good solution
#9

[eluser]Gewa[/eluser]
I made a topic by mistake, the main thing is that with your solution I have such problem.





Code:
$route['sites/([^/]+)/(.*)'] = '$2';
$route['default_controller'] = "content";

By idea when I go to

www.site.com/sites/sitename/

then the base_url=http://site.com/sites/sitename/ and I want that then default page that would be loaded is what I see when i go to

www.site.com/sites/sitename/content/

But I get just 404

What to do?




Theme © iAndrew 2016 - Forum software by © MyBB