.htaccess - uri段2中不允许nuber值,codeigniter
问题描述
我已将 .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
但是说找不到页面。但如果我只保留网址http://local.berger.com/career/那就没问题了。我们不能将数字放在 uri 段 2 中,还是 .htaccess 有问题?任何形式的建议表示赞赏。谢谢。
解决方案
首先使用普通的 .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
}
现在你可以走了。希望对你有效。
推荐阅读
- r - 重复少数类以达到 60%-40% 的关系
- c# - 获取列表中元素参数的索引
- ios - 更新用户界面 Swift
- android - 如何在下面创建带有菜单的 EditText?
- ios - Sygic :the-resource-could-not-be-loaded 因为应用程序传输安全策略需要使用安全连接
- javascript - Angular 动态组件,在另一个组件之前插入
- javascript - 如何使用我的 css 示例制作单选按钮?js
- python - 如何在python中使用win32在xlsx文件中间插入行
- python - Pandas Dataframe, easier syntax to drop rows by condition on values
- sharepoint - 让用户在线登录共享点