CodeIgniter - 获取当前页面路由

Dan*_*nar 1 php codeigniter

我正在创建一个页面访问者模块。目标是了解访问最多的用户,以及访问最多的模块。

我想获取当前页面的页面路由。

这是我想要做的:

  1. 我有一个名为库存模块的模块。
  2. 这个模块有一个路由'merchandiser/report/inventory'。(在routes.php,它是$route['merchandiser/report/inventory'])

这与我想要的路线相同。

我试过了:

<?php echo current_url(); ?>
Run Code Online (Sandbox Code Playgroud)

But it returns something like this.

192.168.3.3/portal/merchandiser/report/inventory
Run Code Online (Sandbox Code Playgroud)

192.168.3.3/portal/ is my base url`

Now my question is:

How can I remove 192.168.3.3/portal/ and just get merchandiser/report/inventory

Hope you can guide me or lead me where to find it.

Thank You.

Pra*_*eep 5

Hope this will help you :

use url helper's

   uri_string();
Run Code Online (Sandbox Code Playgroud)

如果您的网址是这样的:

http://some-site.com/blog/comments/123
Run Code Online (Sandbox Code Playgroud)

该函数将返回:

blog/comments/123
Run Code Online (Sandbox Code Playgroud)

更多信息:https : //www.codeigniter.com/user_guide/helpers/url_helper.html#uri_string

或者你可以使用 uri 类似的东西:

echo $this->uri->segment(1).'/'.$this->uri->segment(2).'/'.$this->uri->segment(3); 

/*produces controller/method/parameter structure
Run Code Online (Sandbox Code Playgroud)

https://www.codeigniter.com/user_guide/libraries/uri.html