2017-02-09 125 views
2

你好,我需要路由笨路由不工作

/tagi/fotografia,51//galeria-sztuki-nowosci/?tags=51

这是唯一的例子OFC。我在routes.php中的代码是:

$route['tagi/(:any),(\d+)'] = function($id) { 
    return 'galeria-sztuki-nowosci/?tags=$id'; 
}; 

它不起作用。

+0

进入的application/config/autoload.php,并添加' 'URL' '在helpers数组中,并且在你的函数中使用它不会返回:''redirect('galeria-sztuki-nowosci /?tags ='。$ id,'location');' –

+0

像这样?$ route ['tagi /任何),(\ d +)'] =函数($ id){redirect('galeria-sztuki-nowosci /?tags ='。$ id,'location');}; –

+0

同样的问题,我也在助手中添加网址 –

回答

1

首先,需要添加逗号在config.php

$配置[ 'permitted_uri_chars'] =:; 'A-Z 0-9〜%_-,'。

下routes.php文件将是

$路线[ “田仪/([A-Z] +),(:任何)”] = '旧/ galleryTags/$ 2';

而且最后需要做的控制器

公共职能galleryTags($标签) {

if ($tags == "_"): $tags = ""; endif; 


    header("Location: /galeria-sztuki-nowosci/?tags=$tags"); 
}