Url codeigniter 中的路由不工作
Url route in codeigniter notworking
application/config/routes.php
$route['aboutus'] = 'footerpage/index/';
Url 路由概念在 codeigniter 中不起作用。
在这里尝试我将 url footerpage/index/1 更改为 aboutus
Url 就像
http:local.com/footerpage/index/1
想变成这样
http:local.com/aboutus
只需使用 .htaccess,如下所示:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^local.com[nc]
RewriteRule ^(.*)$ http://www.local.com/ [r=301,nc]
Redirect 301 /footerpage/index/1 /aboutus
根据我的理解,1 是来自数据库的 id,它不会改变,所以在您的控制器 "footerpage" 和 "index" 函数中,您可以直接将 id 指定为 1 ...无需定义路线中的 ID
在路线中
$route['aboutus'] = 'footerpage/index';
我猜你正在找这个?
$route['footerpage/index/[0-9]+'] = "aboutus";
我假设索引后的数字会有所不同...但是如果不这样更改值,您可以将 [0-9]+
更改为 1
$route['footerpage/index/1'] = "aboutus";
希望对您有所帮助
你应该试试这个:
$route['aboutus/(:any)'] = 'footerpage/index/';
uri 将显示作为变量传递给控制器的参数。
application/config/routes.php
$route['aboutus'] = 'footerpage/index/';
Url 路由概念在 codeigniter 中不起作用。 在这里尝试我将 url footerpage/index/1 更改为 aboutus
Url 就像
http:local.com/footerpage/index/1
想变成这样
http:local.com/aboutus
只需使用 .htaccess,如下所示:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^local.com[nc]
RewriteRule ^(.*)$ http://www.local.com/ [r=301,nc]
Redirect 301 /footerpage/index/1 /aboutus
根据我的理解,1 是来自数据库的 id,它不会改变,所以在您的控制器 "footerpage" 和 "index" 函数中,您可以直接将 id 指定为 1 ...无需定义路线中的 ID
在路线中
$route['aboutus'] = 'footerpage/index';
我猜你正在找这个?
$route['footerpage/index/[0-9]+'] = "aboutus";
我假设索引后的数字会有所不同...但是如果不这样更改值,您可以将 [0-9]+
更改为 1
$route['footerpage/index/1'] = "aboutus";
希望对您有所帮助
你应该试试这个:
$route['aboutus/(:any)'] = 'footerpage/index/';
uri 将显示作为变量传递给控制器的参数。