用于无声重写查询string(如codeigniter)的Apacheconfiguration

Codeigniter重写查询string,如下所示:

http://somedomain.com/index.php?q=something

成为:

http://somedomain.com/index.php/q/something

我想在一个(非常)轻巧的网站上模仿这种行为,我正在开发一个婚礼RSVP系统。 我不想要臃肿的代码,也不需要它提供的任何东西。 我唯一想要的就是这个。

不幸的是,我不知道如何设置一个完成这个的mod-rewrite规则。 我可以设置一个规则来将/q/something翻译成?q=something ,但是我不能在没有改变用户正在查看的URL的情况下得到这样的规则。

我基本上是在寻找一些实际上是重写的“无声”版本。 也就是说,我想要重写q/something ?q=something ,但是将用户的URL保留在地址栏中作为q/something

提前致谢!

编辑

在该网站的.htaccess文件中,我有以下内容:

 RewriteEngine on RewriteRule ^/index.php/q/(.*) /index.php?q=$1 

在网站的基本configuration(/etc/apache2/sites-available/mysite.conf)中,我有:

 <VirtualHost *> ServerAdmin [email protected] ServerName www.mysite.com DocumentRoot /var/www/www.mysite.com Options -Indexes +FollowSymLinks </VirtualHost> 

index.php文件当前只是打印出$_GET['q'] 。 现在,当我访问该网站http://www.mysite.com/index.php?q=12345 ,按预期显示“12345”。 但是,当我导航到http://www.mysite.com/index.php/q/12345 ,它不显示任何东西。 或者,相反,看起来查询string的值是空的。 我不太确定我做错了什么。