我当前的url是universitytwig.com/user/userprofile/cm.cm,其中user是控制器,userprofile是方法和cm。我如何通过route.php或从数据库路由,或通过。htaccess
尝试添加
$route['cm.cm'] = 'user/userprofile/cm.cm';
/config/routes.php
或
$route['(:any)'] = 'user/userprofile/$1';
你可以使用routes.php
,但是如果你用cm这样的单位来制定规则。cm to user/userprofile/cm.cm
$route['(:any)']= 'user/userprofile/$1';
但这不是一个完美的解决方案,它将指向基础url之后的所有东西的所有控制器到user/userprofile/
,您需要指定一些字符串,CI routes
将识别这需要指向此控制器如果cm。cm是动态参数,没有硬编码对于这个url结构应该是
universitytwig.com/students/cm.cm
和在路由中,你现在可以创建一个规则
$route['students/(:any)']= 'user/userprofile/$1';
这将适用于您的场景