在route.php中我尝试了代码
$route['default_controller'] = 'controller';
$route["test"] = 'controller/method/49';
$route["author"] = 'controller/method/48';
$route['404_override'] = '';
as per URI Routing document
But still url is showing www.example.com/controller/method/48 is not routing
我不知道我失踪的地方,
.htaccess文件
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
答案 0 :(得分:0)
在您的路线中,如果您的网址末尾有一个ID号
示例1
www.example.com/controller/method/48
如果只是将数字作为ID,则可以将(:any)
替换为(:num)
$route["controller/method/(:any)"] = 'controller/method/$1';
示例2
www.example.com/test/48
如果只是将数字作为ID,则可以将(:any)
替换为(:num)
$route["test"] = 'controller/index/$1';
$route["test/update/(:any)"] = 'controller/update/$1';
$route["test/add"] = 'controller/add';
和
$route["test1"] = 'controller1/index/$1';
$route["test1/update/(:any)"] = 'controller1/update/$1';
$route["test1/add"] = 'controller1/add';
等等。