2012-02-20 80 views
1

在我的web應用程序我有一個網址,格式如下所示:Codeigniter - 如何獲取和更改uri segement然後重定向?

http://mydomain.com/search/index/list/for-sale/london/0/0/0/0 

我想使用URI類和重定向改變$this->uri->segment(3);map,然後重定向。

所以,一旦重定向和段已經改變URL可能看起來像:

/搜索/索引/地圖/出售/倫敦/ 0/0/0/0

將如何我去做這個?

回答

2

這可能需要一些額外的檢查,但是這將是一個簡單的方法:

$segment_to_replace = "/".$this->uri->segment(3)."/"; 
$new_url = str_replace ($segment_to_replace, "/map/", current_url()); 

redirect ($new_url); 
+0

很不錯的方法。簡單而有效。很高興你明白我的問題。謝謝。 – hairynuggets 2012-02-20 13:59:10