如何将url从/(id)修改为?=(id)


How to change the url from /(id) to ?=(id)

我有一个url,看起来像这样:

/reservations/database/read/1641

如何使它看起来像和函数在参数下工作:

/reservations/database/read?id=1641

我应该编辑什么?是路由的配置还是功能的实现?

.htaacess

RewriteEngine on
RewriteCond $1 !^(index'.php|(.*)'.swf|forums|images|css|downloads|jquery|js|robots'.txt|favicon'.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

也许这对你有帮助。

 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^([^/]+)/?$ index.php?$1 [L,QSA]

我使用这个htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

使用这个,在控制器中获取参数,而不是函数参数:

$this->input->get('id');

那么这个就可以了:

site/controller/method?parameter=value