【问题标题】:Numbered URL in CodeIgniter PHPCodeIgniter PHP 中的编号 URL
【发布时间】:2017-07-07 07:48:11
【问题描述】:

我正在创建一个新网站,并且我希望 URL 都在 numbered form as well as simple text form (just like stackoverflow.com 's URLS) 中,但如果用户使用 url 访问时不调用标题,我就无法这样做

http://MY_WEBSITE/654321

然后转到,说页面链接到abcd,那么 URL 应该是这样的

http://MY_WEBSITE/654321/abcd

但这里abcd654321 都是动态的,因为它们会在链接之间发生变化。

那么,我该怎么做呢?如何在没有header的情况下更改为新网址

欢迎在new way 中实施或解决问题的任何建议!

【问题讨论】:

标签: php codeigniter url redirect header


【解决方案1】:

这使您可以从 URI 字符串中检索信息

$this->uri->segment(n); // n=1 for controller, n=2 for method, etc

示例网址:

http://test.com/index.php/controller/action/1stsegment/2ndsegment 

然后就显示出来了!

$this->uri->segment(1); // controller
$this->uri->segment(2); // action
$this->uri->segment(3); // 1stsegment
$this->uri->segment(4); // 2ndsegment

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-12
    • 2016-02-17
    • 2013-07-01
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多