在coderiiter的uri segment 2中不允许使用数字值

问题描述 投票:0回答:1

我已将.htaccess配置为

    RewriteEngine on
    RewriteBase /
    RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|assets|img|uploaded|admin|source|images|googlexxxxxxxx\.html|mobile.html)
    RewriteRule ^(.*)$ index.php/$1 [L]

我的路由是:

    $route['career/(:any)'] = 'career/index/$1';

我的网址是:

    http://local.berger.com/career/4

但是说没有找到Page。但如果我只是保持网址http://local.berger.com/career/然后它没关系。我们不能把数字放在uri段2中,或者.htaccess有问题吗?任何建议都表示赞赏。谢谢。

.htaccess url-rewriting url-routing codeigniter-3
1个回答
0
投票

首先使用普通的.htaccess在这里你可以得到它。

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
AddDefaultCharset utf-8

之后你的配置文件

$config['index_page'] = 'index.php';

用。。。来代替

$config['index_page'] = '';

你的路线没问题

$route['career/(:any)'] = 'career/index/$1';

现在你的控制器

public function index($variable){
    //code goes here
}

现在你很高兴。希望对你有效。

© www.soinside.com 2019 - 2024. All rights reserved.