简体   繁体   English

Codeigniter路由不重写url

[英]Codeigniter Routing Not Rewriting the url

I am not much expert in codeigniter routing, but i need to rewrite/mask the url 我在codeigniter路由方面不是很多专家,但是我需要重写/屏蔽网址

my actual url is example.com/america/newyork/200/OC/2015/DALL/CALL 我的实际网址是example.com/america/newyork/200/OC/2015/DALL/CALL

Where 200/OC/2015/DALL/CALL is values which i am passing in that page 其中200 / OC / 2015 / DALL / CALL是我在该页面中传递的值

I want to mask the url something like this example.com/america/newyork/ 我想屏蔽网址,例如: example.com/america/newyork/

what i actually done 我实际上做了什么

$route['default_controller'] = "america";
$route['america/newyork/(:any)/(:any)/(:any)/(:any)/(:any)'] = 'america/newyork/$1/$2/$3/$4/$5';

but the above routing seems to be not working of what i expected , may i can know where i making mistake 但是上述路由似乎没有达到我的预期,我可以知道我在哪里出错

Here is my newyork method 这是我的纽约方法

public function newyork($one='',$two='',$three='',$four='',$five='')
    {
        echo $one.''.$two.''.$three.''.$four.''.$five;
    }

Beyond an ID, I've never been able to get CI to load anything from the URL without manually specifying it in the method. 除了ID之外,如果没有在方法中手动指定它,我将永远无法让CI从URL加载任何东西。 So it's probably not going to automatically pull your $one, $two, et cetera. 因此,它可能不会自动拉出您的一美元,二美元等。

But if you load the URI segments in your function (probably not the most efficient way of doing it), maybe you'll get some results. 但是,如果在函数中加载URI段(可能不是最有效的方式),也许会得到一些结果。

$one = $this->uri->segment(whatever_segment_number_here);

This does, of course, require that you autoload the URL helper or load it on-demand in your method. 当然,这确实需要您自动加载URL助手或在您的方法中按需加载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM