infinite redirects for non-existent routes

Hi,

If I request an invalid route that is more than one character in length it results in infinite redirects. E.g.:

http://localhost/blog/about -- works fine

http://localhost/blog/x -- results in dispatch error

http://localhost/blog/xx -- results in infinite redirects

"GET /blog/xx HTTP/1.1" 301 - "GET /blog/xx/ HTTP/1.1" 301 - "GET /blog/xx// HTTP/1.1" 301 - "GET /blog/xx/// HTTP/1.1" 301 - "GET /blog/xx//// HTTP/1.1" 301 - "GET /blog/xx///// HTTP/1.1" 301 - "GET /blog/xx////// HTTP/1.1" 301 - "GET /blog/xx/////// HTTP/1.1" 301 - "GET /blog/xx//////// HTTP/1.1" 301 - "GET /blog/xx///////// HTTP/1.1" 301 - "GET /blog/xx////////// HTTP/1.1" 301 - "GET /blog/xx/////////// HTTP/1.1" 301 -

and it goes on... How can I prevent this? Thanks!

Posted June 1st, 2007 at 12:51pm by Tim

Same problem here ... :(

Posted June 1st, 2007 at 2:05pm by Aaron

I have also the same problem.

It is due to the "trywithtrailing_slash" option when you call PicoraDispatcher::dispatch() (4th param)

To avoid this problem, change the index.php file :

Replace :

print PicoraDispatcher::dispatch($path,BASE_URL,$route, true );

By :

print PicoraDispatcher::dispatch($path,BASE_URL,$route, false );

Posted June 1st, 2007 at 5:16pm by SuperDevy

Thanks for your reply... I actually want to use the try with trailing slash option though. After playing around a little more I changed the call to substr in the following line in PicoraDispatcher::dispatch():

if($try_with_trailing_slash && strlen($requested_url) > 1 && substr($requested_url,0,-1) != '/' && self::dispatch($dispatcher_dir,$base_url,$requested_url.'/',false)){

to:

if($try_with_trailing_slash && strlen($requested_url) > 1 && substr($requested_url,-1,1) != '/' && self::dispatch($dispatcher_dir,$base_url,$requested_url.'/',false)){

It seems to work ok now.

Posted June 4th, 2007 at 1:00pm by Tim

Login or Register to Post