Home>

Apppath/config/config.php for the url format.

$config ["uri_protocol"]="auto";

This configuration item defines which server global variable you use to develop the URL.

The default setting is auto, which polls the following four methods.When your link doesn't work,Try using options other than auto.

"auto" default-auto detects

"path_info" uses the path_info

"query_string" uses the query_string

"request_uri" uses the request_uri

"orig_path_info" uses the orig_path_info

Several member variables in ci_uri

$keyval=array ();//list of cached uri segments
$uri_string;//current uri string
$segments //list of uri segments
$rsegments=array () //re-indexed list of uri segments

The obtained current uri string is assigned to $uri_string through function _set_uri_string ($str).

There are several options for getting $str,This is the business process part of _fetch_uri_string ()

First, the default

$config ["uri_protocol"]="auto"

, The program will poll the following methods once to get the uri

(1) When the program runs under cli,That is, when the php file is on the command line.ci will get uri like this

private function _parse_cli_args ()
{
  $args=array_slice ($_ server ["argv"], 1);
  return $args?"/" .implode ("/", $args):"";
}

$_server ["argv"] contains the parameters passed to the script. When the script runs in cli, it will give the command line parameters in c

Intercept all parameters except $1 in $_server ["argv"]

If you do this from the command line

php d:\ wamp \ www \ codeigniter \ index.php \ start \ index

_parse_cli_args () returns a string of /index.php/start/index

(2) The private function _detect_uri () is called when request_uri is used to detect the URL by default.

(3) If uri cannot be obtained by the above two methods, $_server ["path_info"] will be used to obtain the uri.

$path=(isset ($_ server ["path_info"]))?$_server ["path_info"]:@getenv ("path_info");
if (trim ($path, "/")!="" && $path!="/".self)
{
  $this->_set_uri_string ($path);
  return;
}

(4) If none of the above three methods can be obtained,Then use

$_server ["query_string"] or getenv ["query_string"]

$path=(isset ($_ server ["query_string"]))?$_server ["query_string"]:@getenv ("query_string");
if (trim ($path, "/")!="")
{
  $this->_set_uri_string ($path);
  return;
}

(5) None of the above four methods can get uri, then you must use the $_get array, no trick

if (is_array ($_ get)&&count ($_ get) == 1&&trim (key ($_ get), "/")!="")
{
  $this->_set_uri_string (key ($_ get));
  return;
}

Second, set in config.php:

$config ["uri_protocol"]

Then the program will automatically perform the corresponding operation to obtain the uri

php
  • Previous Analysis of CI framework integrated Smarty
  • Next Seventy of Manipulating Data in ASPNET 20: Configuring Database Connections and Command Level Settings