Welcome Guest, Not a member yet? Register   Sign In
CI 3 URI::_parse_request_uri() function
#1

I am setting up CodeIgniter 3 RC3.

I have an app called my_app.

On my Web server I created a folder named "my_app" and in this folder I created index.php file which is a symlink to actual CodeIgniter index.php

So the directory structure is something like this:

Code:
+--www
  |
  +--example.org
     |
     +--CodeIgniter
     |  |
     |  +--applications
     |  +--system
     |  +--user_guide
     |  +--my_app.php
     |
     +--htdocs
        |
        +--my_app
           |
           +--index.php -> ../../CodeIgniter/my_app.php

Apache is set to reroute all requests to my_app folder to the my_app/index.php. In this way there is no index.php in browser's URL input field.

So whenever I visit www://example.org/my_app the my_app.php within CodeIgniter is being called.

To call a particular method in the controller I will call www://example.org/my_app/method.

But here is the problem:

There is _parse_request_uri() function in the CI_URI class where I found following code:

PHP Code:
if (strpos($uri$_SERVER['SCRIPT_NAME']) === 0)
{
 
   $uri = (string) substr($uristrlen($_SERVER['SCRIPT_NAME']));
}
elseif (
strpos($uridirname($_SERVER['SCRIPT_NAME'])) === 0)
{
 
   $uri = (string) substr($uristrlen(dirname($_SERVER['SCRIPT_NAME'])));


Per this code snippet if URI starts with the directory name of the script, the directory name gets chopped off. And this appears to break my setup.

If I call www://example.org/my_app/method, the htdocs/my_app/index.php is being called.

PHP Code:
dirname($_SERVER['SCRIPT_NAME']) 
evaluates to my_app and

PHP Code:
elseif (strpos($uridirname($_SERVER['SCRIPT_NAME'])) === 0
evaluates to true, thus

modifying original URI my_app/method to just method

There is no controller method and as result I am getting error 404.



Can anyone here explain what is the purpose of the above code snippet and why is it needed? I am wondering only because I managed to run into trouble while implementing new setup with CodeIgniter.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB