• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner, needs help with routes.php

#1
[eluser]canado[/eluser]
Hello everyone

I have a small problem that I found with charles web debugging
When my site loads it loads 2 times the default controller and then the view corresponding to the uri.

Which means that if I load the home page, in charles web debugging I see
home
home
home

if I load another controller I have
other controller (request start time 20/02/12 8:08:19AM)
home (request start time 20/02/12 8:08:20AM)
home (request start time 20/02/12 8:08:20AM)

Maybe there is something either wrong or something else I must do to avoid loading the correct controller + 2 times the default controller
Here is my routes.php, thanks

Code:
[php]
$route['.*/(products|produits)/(.*)[0-9]+$'] = 'item';
$route['.*/(products|produits)/.*'] = 'products';


$route['default_controller'] = "home";
$route['404_override'] = 'site/site_404';

// URI like '/en/about' -> use controller 'about'
$route['^(en|fr)/(.+)$'] = "$2";

// '/en' and '/fr' URIs -> use default controller
$route['^(en|fr)$'] = $route['default_controller'];

// + routes for multilangue
$route['en/home'] ="home";
$route['fr/accueil'] ="home";

$route['fr/produits'] = "products";
$route['fr/caddy'] ="caddy";
$route['en/caddy'] ="caddy";

[/php]

#2
[eluser]InsiteFX[/eluser]
The default controller should always be the first one defined.
Code:
$route['default_controller'] = "home";
$route['404_override'] = 'site/site_404';

$route['.*/(products|produits)/(.*)[0-9]+$'] = 'item';
$route['.*/(products|produits)/.*'] = 'products';

// URI like '/en/about' -> use controller 'about'
$route['^(en|fr)/(.+)$'] = "$2";

// '/en' and '/fr' URIs -> use default controller
$route['^(en|fr)$'] = $route['default_controller'];

// + routes for multilangue
$route['en/home'] ="home";
$route['fr/accueil'] ="home";

$route['fr/produits'] = "products";
$route['fr/caddy'] ="caddy";
$route['en/caddy'] ="caddy";

#3
[eluser]canado[/eluser]
thanks, I did what you suggested me, but I still have the same issue ;(

#4
[eluser]Aken[/eluser]
Do you have any Ajax calls running on your pages?

#5
[eluser]canado[/eluser]
yes I do have ajax calls

#6
[eluser]Aken[/eluser]
... That's a hint for "If you have Ajax calls, make sure they're calling correctly and not just grabbing the home page."

#7
[eluser]canado[/eluser]
I have ajax calls but only on click and on that page it s not going to the home controller ; (

#8
[eluser]meigwilym[/eluser]
OK,if this is for the homepage, then I suggest commenting out all the custom routes and reloading the page. If it still happens then it's not your routing.

Otherwise, add each route back one at a time and repeat.

Regards,

Mei

#9
[eluser]canado[/eluser]
ok thanks I ll do that ; - )


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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