为什么这个mod_rewrite规则不能与CodeIgniter一起使用?

时间:2013-04-08 18:24:40

标签: .htaccess codeigniter mod-rewrite

RewriteRule ^(new-york/new-york-city/chelsea/10001) index.php [L]

上述代码不起作用。它在Codeigniter中给出了404错误。但是,以下代码确实有效。

RewriteRule ^(new-york/new-york-city/chelsea/10001) http://anywebsitehere.com/ [L]

1 个答案:

答案 0 :(得分:0)

如果您有一个设置,RewriteRule只会重写为index.php,它会调用默认路由。如果你想进行搜索,你必须重写搜索控制器和方法,并将漂亮的URL或部分URL作为参数传递

RewriteRule ^new-york/new-york-city/chelsea/10001 index.php/search_controller/search_method/$0 [L]

这将使用漂亮的URL作为参数调用application/controllers/search_controller.php方法search_method

search_method('new-york', 'new-york-city', 'chelsea', '10001');
相关问题