Apache codeigniter的重写规则

Apache codeigniter的重写规则,apache,mod-rewrite,codeigniter,Apache,Mod Rewrite,Codeigniter,这是我在CI中的控制器 class Welcome extends Controller { function Welcome() { parent::Controller(); } function index() { } function bil($model='') { } 我想重写一下,这样 http://example.com/index.php/welcome/bil/model 变成 http://example.com/model 在我的电脑里

这是我在CI中的控制器

class Welcome extends Controller {

 function Welcome()
 {
  parent::Controller(); 
  }

 function index()
 {

 }
 function bil($model='')
 { }
我想重写一下,这样

http://example.com/index.php/welcome/bil/model
变成

http://example.com/model
在我的电脑里我有

RewriteBase /
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/welcome/$1 [L]
#RewriteRule ^(.*)$ /index.php/welcome/bil/$1 [L]
我认为这应该和删除/index.php/welcome/part一样简单
但是当我取消注释最后一行时,它会出现500个内部服务器错误

您将希望使用mod_rewrite删除index.php文件,就像上面一样,但是使用它将example.com/model重新路由到example.com/welcome/bil/model

在routes.php配置文件中,您可以定义如下所示的新路由:

// a URL with anything after example.com 
// will get remapped to the "welcome" class and the "bil" function, 
// passing the match as a variable
$route['(:any)'] = "welcome/bil/$1";
因此,输入example.com/abc123将等同于example.com/welcome/bil/abc123

请注意,URL中只允许位于config.php文件中的$config['allowed_uri_chars']所允许的字符

希望有帮助