CodeIgniter Forums
Bug in URI Class since 2.0.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Bug in URI Class since 2.0.1 (/thread-43345.html)



Bug in URI Class since 2.0.1 - El Forum - 07-08-2011

[eluser]Unknown[/eluser]
Hi,

I've found a bug in the URI-Class since 2.0.1. Im using a subfolder in controllers for my backoffice-controllers, rewriting all requests from backoffice.domain.tld to /backoffice/$1 using:

Code:
RewriteCond %{HTTP_HOST} ^backoffice\.domain\.tld
RewriteCond %{REQUEST_URI} !^/backoffice
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /backoffice/$1 [L]

However since 2.0.1 this will not load the /backoffice/default_controller-controller, it will instead load the root default_controller. When i debugged the code i found out that $uri is empty for my request to backoffice.domain.tld and if it was kept empty it worked, but not if a second trailing slash was added like the way in 2.0.1 and 2.0.2:

Code:
if ($uri == '/' || empty($uri))
{
  return '/';
}

This fixes the problem:

Code:
if ($uri == '/')
{
  return '/';
}
        
if (empty($uri))
{
  return '';
}

The second trailing slash might not be working because of my setup (Apache2.2.17 on OSX) but still, if anyone have the same problem this fix works.


Bug in URI Class since 2.0.1 - El Forum - 07-08-2011

[eluser]RJ[/eluser]
You should add the bug to bitbucket if you havent already.