Php ci中的动态段URL
我想从更改我的URL www.mydomain.com/data/2 到 www.mydomain.com/name-data 我试着像这样在我的Php ci中的动态段URL,php,codeigniter,routes,Php,Codeigniter,Routes,我想从更改我的URL www.mydomain.com/data/2 到 www.mydomain.com/name-data 我试着像这样在我的routes.php中进行配置 $route['(.*)'] = 'data/$1'; $route['login-resgistration'] = 'f/login/index'; 但当我在地址栏上输入时 www.mydomain.com/login-registration 或 www.mydomain.com/anotherword 它返回数
routes.php
中进行配置
$route['(.*)'] = 'data/$1';
$route['login-resgistration'] = 'f/login/index';
但当我在地址栏上输入时
www.mydomain.com/login-registration
或
www.mydomain.com/anotherword
它返回数据控制器。您必须在主数据控制器路由之前声明所有路由
$route['login-resgistration'] = 'f/login/index';
$route['my-account'] = 'f/login/myaccount';
$route['(.*)'] = 'data/$1';
希望这能起作用。在CI中设置路由和if时,而不是
http://my,website.com/MyController/MyFuction/param1/param2
您想创建一个类似http://my.website.com/page1-param1-param2
设置它的方法是在。/config/routes.php->$route[“page1-(:any)-(:any)”]=“MyController/MyFuction/$1/$2”
但是首先检查你写的拼写错误,重新注册可能是在你的代码或你键入的URL注册中。我不做拼写错误。仍然需要返回到DataControllerCare来解释f在f/login/index
中的含义,以及自动访问索引函数的方式,例如:MyController/index->$route[“某些名称”]=“MyController”
这只是一个例子,当我向另一个函数声明时,比如$route['my-account']='f/login/myaccount'
它仍然返回到数据控制器