Php 使用多站点codeigniter脚本的htaccess

Php 使用多站点codeigniter脚本的htaccess,php,apache,.htaccess,codeigniter,Php,Apache,.htaccess,Codeigniter,大家好,我正在使用codeigniter制作多个站点脚本, 1-我使用htaccess删除index.php 2-我让多个站点在同一个文件上工作,所以我想在GET参数中传递站点名称,所以我想要一个htaccess代码来实现这一点 http://site_url.com/index.php/controller?site=username 把这个联系起来 http://site_url.com/username/controller 这是我用来删除index.php的基本代码,所以我的问题

大家好,我正在使用codeigniter制作多个站点脚本, 1-我使用htaccess删除index.php 2-我让多个站点在同一个文件上工作,所以我想在GET参数中传递站点名称,所以我想要一个htaccess代码来实现这一点

  • http://site_url.com/index.php/controller?site=username
把这个联系起来

  • http://site_url.com/username/controller
这是我用来删除index.php的基本代码,所以我的问题是site参数

Options +FollowSymLinks 
RewriteEngine on 

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
有什么想法吗

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([A-Za-z0-9]+)/main index.php/main?site=$1 [L]

对于htaccess,我只是一个“noob”,但这就是我如何尝试的

当我输入时,我得到404错误,当我输入时,我也得到404错误(无法加载默认控制器。请确保在Routes.php文件中指定的控制器是有效的)。但是当我输入时,我得到控制器索引函数,但在$\u get中没有参数,有什么想法吗?因为用户名和控制器名称都是必需的,并且您需要在config.php中将uri_协议更改为PATH_INFO,$config['uri_protocol']='PATH_INFO';您可以在config/routes.php文件=>$route['default\u controller']=“controller/index”中设置默认控制器;
RewriteEngine on
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z]+)$ index.php/$2?site=$1 [L,E]